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
OPS-MLTSD
Post Patron
Post Patron

Help with DAX to be able to filter for percent of grand total

Hello,

 

I am trying to write a dax for a table where I am planning on showing the percentage for the 3 groups that I have. So I want the data to look like this:

GroupDistinct Events% of events
A600028%
B1000048%
C500024%
Total21000100%

 

I have a slicer right beside this tabe where I have the 3 groups listed. The problem is, when I click on one of the groups, the data shows up like this:

GroupDistinct Events% of events
A6000100%
Total6000100%

 

I created a measure using the Event ID like this: 

Distinct Events = DISTINCTCOUNT(Event[EventID]) 

 

I used this measure in the table and used the same measure again and clicked "show value as percentage of grand total". I am wondering, is there a way that I can create a dax measure for the percentage values only for "% of events" so that when I click on one of the groups in the slicer, it will show the correct percentage. For example if I click group A, it will show up as:

 

GroupDistinct Events% of events
A600028%
Total600028%

 

If someone could please help me create that measure, that would be much appreciated. Thank you

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

Try:

% of events = 
DIVIDE(
DISTINCTCOUNT(Event[EventID]),
CALCULATE( DISTINCTCOUNT(Event[EventID] ), ALL(Event[EventID]))
)

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

5 REPLIES 5
PaulDBrown
Community Champion
Community Champion

Try:

% of events = 
DIVIDE(
DISTINCTCOUNT(Event[EventID]),
CALCULATE( DISTINCTCOUNT(Event[EventID] ), ALL(Event[EventID]))
)

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown  Thanks I tried the dax that you created, except, it still gave me 100% for all the groups even after choosing one of the groups in the slicer but when I removed the last event ID from the dax, it worked, I will still accept your response as the solution 🙂

I was wondering if you could explain the difference between ALL and ALLSELECTED?

% of events = 
DIVIDE(
DISTINCTCOUNT(Event[EventID]),
CALCULATE( DISTINCTCOUNT(Event[EventID] ), ALL(Event))
)

 

Apologies, my mistake. It should have been:

 

% of events = 
DIVIDE(
DISTINCTCOUNT(Event[EventID]),
CALCULATE( DISTINCTCOUNT(Event[EventID] ), ALL( Table [Group] ))
)

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown should it be "ALL( Event [Group] )" or "ALL(Event)"? Because it works when I don't specifcy a particular column

If ALL(Event) works, go for it!!





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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.