Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
pgardella
New Member

Average users per group

Good morning!  I am just starting to use PowerBI and DAX, and have been frustrated by what seems like it should be an easy thing.

 

Given a table like this:

 

Group_NameGroup_IDUser_ID
Group 11100
Group 11200
Group 11300
Group 22100

 

I want to calculate the average number of people per group. In this case "2" ((3 + 1)/2). I've tried setting up a second table based using SUMMARIZE, so it ends up like:

Group_IDUserCount
13
21

And then tried to calculate the AVERAGE of that new table.  But my SUMMARIZE never turns out right. 

 

SUMMARIZE(group_user_links,group_user_links[group_id], "UserCount", DISTINCTCOUNT(group_user_links[user_id])) or

SUMMARIZE(group_user_links,group_user_links[group_id], "UserCount", COUNTX(group_user_links, group_user_links[user_id])) end up way too high.

 

Is that the best way to go about it? Or is there a better way?

 

Patrick+

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@pgardella This should work! Smiley Happy

 

User Per Group =
DIVIDE (
    CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Group_ID] ) ),
    DISTINCTCOUNT ( 'Table'[Group_Name] ),
    0
)

2016-10-28 - Users Per Group.png

View solution in original post

2 REPLIES 2
Sean
Community Champion
Community Champion

@pgardella This should work! Smiley Happy

 

User Per Group =
DIVIDE (
    CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Group_ID] ) ),
    DISTINCTCOUNT ( 'Table'[Group_Name] ),
    0
)

2016-10-28 - Users Per Group.png

Well, that is one way I hadn't even considered!  Thank you!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.