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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
arb1782
Helper III
Helper III

Dax for average group size measure

Hi

 

I've just modelled some data so that I have each row is an individual who has attending a health group. I want to create a measure that shows the average number of group participants.

 

My data is structured like this:

 

Group IDDate of groupGroup namePerson ID
1

12/09/20

Health groupA
1

12/09/20

Health groupB
1

12/09/20

Health groupC
213/09/20Disability groupD
213/09/20Disability groupE
314/09/20Exercise groupA
314/09/20Exercise groupC
314/09/20Exercise groupG
314/09/20Exercise groupH

 

What would be the DAX for this?

 

Thanks

arb

1 ACCEPTED SOLUTION

Hi,

Try this measure

=countrows(Data)/distinctcount(Data[Group ID])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

10 REPLIES 10
amitchandak
Super User
Super User

@arb1782 , Try like


AvergaeX(Values(Table[Group ID]), count(Table[Person ID]))

or

AvergaeX(summarize(Table[Group ID],"_1", count(Table[Person ID])),[_1])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi

 

The answer from the sample data should be 3. So far the table and the two formulae provided don't solve my issue.

 

Thanks for responses so far.

Hi,

Try this measure

=countrows(Data)/distinctcount(Data[Group ID])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks all

Any other ideas @amitchandak  @VijayP  @negi007  ?

Anonymous
Not applicable

Hi @arb1782 ,

You can create a measure as below:

Measure =
VAR _countofallp =
    CALCULATE ( COUNT ( 'Table'[Person ID] ), ALL ( 'Table' ) )
VAR _countofgroup =
    CALCULATE ( DISTINCTCOUNT ( 'Table'[Group ID] ) )
RETURN
    DIVIDE ( _countofallp, _countofgroup, 0 )​​​

Best Regards

Rena

 

 

Thanks @Anonymous 

 

I get the following error: "The following syntax error occurred during parsing: Invalid token, Line 7, Offset 46, ." The little red squiggle is after the final bracket of the DIVIDE.

 

Any idea how to resolve this?

Anonymous
Not applicable

Hi @arb1782 ,

Sorry, I made a mistake... The error message is caused by the wrong use of the last bracket in the formula, please update the formula of measure as below:

Measure =
VAR _countofallp =
CALCULATE ( COUNT ( 'Table'[Person ID] ), ALL ( 'Table' ) )
VAR _countofgroup =
CALCULATE ( DISTINCTCOUNT ( 'Table'[Group ID] ) )
RETURN
DIVIDE ( _countofallp, _countofgroup, 0 )

In addition, you can use DAX Formatter tool to check if there are any syntax errors in your formula and format it.

Best Regards

Rena

VijayP
Super User
Super User

@arb1782 

Do you want to have this as a result?

2020-09-21_211727.png




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


negi007
Community Champion
Community Champion

@arb1782 If you only wish to calculate the number of participant per group, there is no need to create a measure. it can be done simply using below approach. Put person ID in the values field and change the calculation to count from the dropdown icon

 

negi007_0-1600702856355.png

 




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.