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
codebrane
Frequent Visitor

Alternative to multiple measures for totals

I seem to be creating lots and lots of simple measures along the lines of:

 

_total_of_this = CALCULATE(COUNT('The Table'[Something]),VALUE('The Table'[Something]) > 0)

 

across more than 30 fields to get totals for bar graphs. I was wondering if there's a more efficient way to do this, other than multiple measures that differ only in the column they work on?

 

Also, I prefix them with _ so they bubble to the top and keep separate from fields as there doesn't appear to be way to organise anything in power bi desktop. I've used powershell to create them in the past but that no longer works in 2.79.5768.721.

 

thanks,

 

Alistair

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @codebrane

 

Do you mean that you wanna combine multiple measures into less measures?

If so ,are these measures applied to the same column or the same value?In this case,you can use switch() function,such as  

 

MEASURE= SWITCH(SELECETEDVALUE(COLUMN 1),"A",[measure 1],"B","measure 2"...).

 

Here is a sample .pbix  you can refer to.

 

BUT if you wanna find the measures more easier, you can create a measure table with no filed inside,then move the measures to the table one by one.

Select the measure>go to the menu bar>move the measure to the measure table.

 

Annotation 2020-03-26 142429.png

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
 

 

 

 

View solution in original post

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi @codebrane

 

Do you mean that you wanna combine multiple measures into less measures?

If so ,are these measures applied to the same column or the same value?In this case,you can use switch() function,such as  

 

MEASURE= SWITCH(SELECETEDVALUE(COLUMN 1),"A",[measure 1],"B","measure 2"...).

 

Here is a sample .pbix  you can refer to.

 

BUT if you wanna find the measures more easier, you can create a measure table with no filed inside,then move the measures to the table one by one.

Select the measure>go to the menu bar>move the measure to the measure table.

 

Annotation 2020-03-26 142429.png

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
 

 

 

 

amitchandak
Super User
Super User

You can put a visual or page level filter for >0 and simply drag the column on visual and change aggregation to count

sorry, forgot to say, some of the data has 0-10, some has letters and some has true/false, all on the same bar graph. So could have:

 

_total = CALCULATE(COUNT('The Table'[Gender]),FORMAT('The Table'[Gender], "") = "M")

 

as well as 0-10 etc

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.

Top Solution Authors