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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
minapot
Frequent Visitor

how to show average as total for distinctcount measure

Hi! I need help again on how to show the correct average total for a measure I created. In this example, Allentown needs to have 114 as total, ie, 118 +116 +115 +113 +110 = 572/5

 

Capture.JPG

 

Thanks for the help!

1 ACCEPTED SOLUTION
danextian
Super User
Super User

HI @minapot

 

If I get it right, the values in columns 1-5 are the distinct count of employees and you want to show the average of these values in the total. Correct?  If so, use this formula: 

 

 

Average =
VAR AVERAGE_ =
    AVERAGEX ( ALL ( 'Table'[Number] ), [Distinct Count] )
RETURN
    ( IF ( HASONEVALUE ( 'Table'[Number] ), [Distinct Count], AVERAGE_ ) )

 

 

The AVERAGE_ variable takes the value of Distinct Count measure and divides the total by the number of unique values in the number column.  

 

Then in RETURN argument,  HASONEVALUE returns Disctinct Count measure when the context for Number column has been filtered down to one distinct value only. Since the Total in the matrix chart is not one distinct value, the AVERAGE_ variable is being returned.

 

averagex.png

 

 

Take note that if you put Number column in a slicer and select at least two values, the result will still be equal to 114.

If you want to show the average of just the selected values in  Number column change 

ALL ( 'Table'[Number] )

 to

ALLSELECTED ( 'Table'[Number] )

 










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

5 REPLIES 5
danextian
Super User
Super User

HI @minapot

 

If I get it right, the values in columns 1-5 are the distinct count of employees and you want to show the average of these values in the total. Correct?  If so, use this formula: 

 

 

Average =
VAR AVERAGE_ =
    AVERAGEX ( ALL ( 'Table'[Number] ), [Distinct Count] )
RETURN
    ( IF ( HASONEVALUE ( 'Table'[Number] ), [Distinct Count], AVERAGE_ ) )

 

 

The AVERAGE_ variable takes the value of Distinct Count measure and divides the total by the number of unique values in the number column.  

 

Then in RETURN argument,  HASONEVALUE returns Disctinct Count measure when the context for Number column has been filtered down to one distinct value only. Since the Total in the matrix chart is not one distinct value, the AVERAGE_ variable is being returned.

 

averagex.png

 

 

Take note that if you put Number column in a slicer and select at least two values, the result will still be equal to 114.

If you want to show the average of just the selected values in  Number column change 

ALL ( 'Table'[Number] )

 to

ALLSELECTED ( 'Table'[Number] )

 










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

That worked! Thanks danextian!

You're welcome!










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

I may miss somthing

 

Total = SUMX(Table2,(Table2[1]+Table2[2]+Table2[3]+Table2[4]+Table2[5])/5)

2018-04-20_9-18-13.png

 

 

 

Greg_Deckler
Super User
Super User

This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.