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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
BobJohnson
Frequent Visitor

Measure that will show Percentage of distinct rows per ID

Hi All,

 

Can you help me figure out how to create a measure that will show % of specific Rating per ID. 

I have multiple rows of the same ID with different Ratings, i need to find out the percentage of each individual rating per ID.

BobJohnson_0-1679395424727.png

I will merge ID with seqence numbers as they should be treated as separate. 

Let's use the top ID 00001-1-1 as an example. It has one amber and one green rating. I would like to know a way of showing that this ID has 50% Red and 50% Green rating and so on.

 

As a note I will only be interested in Amber and Red ratings. Is there a way to show a table with just one row per ID, with columns Red and Amber shown as percentage? 

 

Thanks in advance,

Bob

2 ACCEPTED SOLUTIONS

Hi Stephen, 

 

It mostly works however since there are multiple lines per ID it only shows what percentage of rating is per that line. 

So in this instance we have 3 ID's.

BobJohnson_0-1679565616519.png

As long as filter is set for all ratings, ID 00001 shows 50%green and 50% amber. When I filter to just Amber it shows id 00001 as 100% amber.

BobJohnson_1-1679565743005.png

Is there anyhting that could show all of the ID's that for instance have over 20% red?

If i filter with the current measure it will only highlight the lines with rating Red and shows it as 100%. 

 

Thanks,

Bob

View solution in original post

Hi @BobJohnson ,

 

I am sorry for my negligence and based on my research, in the measure I provided earlier, ALLSELECTED should be replaced with ALL. Because ALLSELECTED preserves the filtering of filters, ALL ignores all filters.

Percentage = var _count1=CALCULATE(COUNT('Table'[ID]),FILTER(ALL('Table'),[ID]=MAX('Table'[ID])))
var _count2=CALCULATE(COUNT('Table'[Rating]),FILTER(ALL('Table'),[Rating]=MAX('Table'[Rating])&&[ID]=MAX('Table'[ID])))
return DIVIDE(_count2,_count1)

vstephenmsft_0-1679983634380.png

Then this should be the best practice at the moment, and it seems more difficult for a row of ID to show the percentage of red and amber.

 

   

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

View solution in original post

4 REPLIES 4
v-stephen-msft
Community Support
Community Support

Hi @BobJohnson ,

 

Here's the measure.

Percentage = var _count1=CALCULATE(COUNT('Table'[ID]),FILTER(ALLSELECTED('Table'),[ID]=MAX('Table'[ID])))
var _count2=CALCULATE(COUNT('Table'[Rating]),FILTER(ALLSELECTED('Table'),[Rating]=MAX('Table'[Rating])&&[ID]=MAX('Table'[ID])))
return DIVIDE(_count2,_count1)

You can set up filters for the visual as follows.

vstephenmsft_0-1679559049137.png

 

   

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

Hi Stephen, 

 

It mostly works however since there are multiple lines per ID it only shows what percentage of rating is per that line. 

So in this instance we have 3 ID's.

BobJohnson_0-1679565616519.png

As long as filter is set for all ratings, ID 00001 shows 50%green and 50% amber. When I filter to just Amber it shows id 00001 as 100% amber.

BobJohnson_1-1679565743005.png

Is there anyhting that could show all of the ID's that for instance have over 20% red?

If i filter with the current measure it will only highlight the lines with rating Red and shows it as 100%. 

 

Thanks,

Bob

Hi @BobJohnson ,

 

I am sorry for my negligence and based on my research, in the measure I provided earlier, ALLSELECTED should be replaced with ALL. Because ALLSELECTED preserves the filtering of filters, ALL ignores all filters.

Percentage = var _count1=CALCULATE(COUNT('Table'[ID]),FILTER(ALL('Table'),[ID]=MAX('Table'[ID])))
var _count2=CALCULATE(COUNT('Table'[Rating]),FILTER(ALL('Table'),[Rating]=MAX('Table'[Rating])&&[ID]=MAX('Table'[ID])))
return DIVIDE(_count2,_count1)

vstephenmsft_0-1679983634380.png

Then this should be the best practice at the moment, and it seems more difficult for a row of ID to show the percentage of red and amber.

 

   

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

Thanks for reply Stephen,

 

Perfect, it works.

 

Regards, Bob

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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