How many users have an achievement?

I need to get the number (not a list) of community members that have received an achievement award.   For example how many people have the "Ask A Question I" achievement.  I thought I could do this in ADMIN > MEMBERSHIP > ACHIEVEMENTS but that only shows me the avatars I would have to manually count.  Some achievements could have hundreds of achievers so this isn't realistic.  Any ideas?   Thanks in advance. 

Parents
  • There isn't a UI for viewing these totals, but it's possible to safely get this data from the API. For example, the following snippet will give you a total count of users with the "Ask A Question I" achievement, which has an ID of 460ac7df-7ccc-4c42-a204-9e05eef3be09.

    $core_v2_userAchievement.List("%{AchievementId = '460ac7df-7ccc-4c42-a204-9e05eef3be09', PageIndex = 0, PageSize = 1 }").TotalCount

    You can run this in a widget, or just in the Script Sandbox in Administration > Interface > Widgets. The pattern of getting counts via List() calls with page sizes of 1 and relying on the TotalCount property is quite common in the platform. You can also do this through the equivalent REST endpoint.

    To retrieve the ID for an achievement, you can use the $core_v2_achievement API.

Reply
  • There isn't a UI for viewing these totals, but it's possible to safely get this data from the API. For example, the following snippet will give you a total count of users with the "Ask A Question I" achievement, which has an ID of 460ac7df-7ccc-4c42-a204-9e05eef3be09.

    $core_v2_userAchievement.List("%{AchievementId = '460ac7df-7ccc-4c42-a204-9e05eef3be09', PageIndex = 0, PageSize = 1 }").TotalCount

    You can run this in a widget, or just in the Script Sandbox in Administration > Interface > Widgets. The pattern of getting counts via List() calls with page sizes of 1 and relying on the TotalCount property is quite common in the platform. You can also do this through the equivalent REST endpoint.

    To retrieve the ID for an achievement, you can use the $core_v2_achievement API.

Children
No Data