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
ninos-shiba
Resolver I
Resolver I

Is it possible to create a single dynamic measure for a similar filtered calculation?

I currently have the following similar measures, all doing the same calculation, except the numerator is filtered for the different values in the "Animal Type" column.

 

% of Cats = CALCULATE(COUNT([Animal]), [AnimalType] = "Cat") / COUNT([Animal])

% of Dogs = CALCULATE(COUNT([Animal]), [AnimalType] = "Dog") / COUNT([Animal])

% of Horses = CALCULATE(COUNT([Animal]), [AnimalType] = "Horse") / COUNT([Animal])

% of Cows = CALCULATE(COUNT([Animal]), [AnimalType] = "Cow") / COUNT([Animal])

 

Instead of 4 different measures, is there a way to have a single measure to do a calculation? On a visual, I would still want to visualize all 4 line measures. But is there a more efficient way of creating filtered measures?

 

The column AnimalType has the values: Cat, Dog, Horse, Cow.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@ninos-shiba Try:

% of Animal = DIVIDE(COUNT([Animal]), COUNTROWS(ALL('Table')))

Use your Animal column in your Legend.


@ 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...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

@ninos-shiba Try:

% of Animal = DIVIDE(COUNT([Animal]), COUNTROWS(ALL('Table')))

Use your Animal column in your Legend.


@ 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
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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