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
Martenandersson
Regular Visitor

Rank Several measures

Hello

 

I have a excel tabel with 30 columns, in each column the data could be "Yes", "No" or "N/A". I have done measures that is in percent "No" of totals for each column. I now want to see the 4 higest values, depending on filter/slicer. Filter is for example city or region. Can anyone please help me?

1 ACCEPTED SOLUTION

Hi @Martenandersson ,

Please try to update the formula of measure [percent "No" of totals] as below and check whether it can be filtered correctly. You can find the details in the attachment.

percent "No" of totals =
VAR _numberofno =
CALCULATE (
COUNT ( 'Table'[Value] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Columns] = SELECTEDVALUE ( 'Table'[Columns] )
&& 'Table'[Value] = "No"
)
)
VAR _count =
CALCULATE (
COUNT ( 'Table'[Value] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Columns] = SELECTEDVALUE ( 'Table'[Columns] )
)
)
RETURN
DIVIDE ( IF ( ISBLANK ( _numberofno ), 0, _numberofno ), _count, 0 )

yingyinr_0-1632992578563.png

If the above one is not working, please provide some sample data included with region,date field and your expected result with backend logic and specific examples. Thank you.

Best Regards

Community Support Team _ Rena
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

6 REPLIES 6
Fowmy
Super User
Super User

@Martenandersson 

I think you have created 30 measures one for each column, The ideal approach is to unpivot your data avoid creating so many measures, and make your other calculations easier. 

If you can share a sample or dummy data in Excel or CSV then a solution can be quick.
I you want know how to UnPivot please refer to videos here: https://www.youtube.com/c/ExcelFort

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Yes, Fowmy. I have done like 30 measure. One for each column. I will check the unpivot in youtube and try that. BUt the next thing is to just show the 4 higest measure of all measures.

Dont know how to attach a sample file here 🙂 But looks like the table below

 

 

CityTest 1Test 2Test 3

Stockholm

Yes

NoN/A
GöteborgNoNoYes
StockholmNoNoNo
GöteborgYesYesYes
StockholmYesYesYes
StockholmYesNoNo

 

Hi @Martenandersson ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Unpivot all of these columns which include the value "Yes" or "No" in Power Query Editor just as suggested by @Fowmy 

yingyinr_0-1632889948619.png

2. Create two measures as below to get the percent of "No" value and Rank

 

percent "No" of totals = 
VAR _numberofno =
    CALCULATE (
        COUNT ( 'Table'[Value] ),
        ALLEXCEPT ( 'Table', 'Table'[Columns] ),
        'Table'[Value] = "No"
    )
VAR _count =
    CALCULATE ( COUNT ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Columns] ) )
RETURN
    DIVIDE ( IF ( ISBLANK ( _numberofno ), 0, _numberofno ), _count, 0 )
Rank = 
RANKX (
    ALLSELECTED ( 'Table' ),
    CALCULATE ( [percent "No" of totals] ),
    ,
    DESC,
    DENSE
)

 

3. Create the visual and apply the filter with the condition "Rank<=4"

yingyinr_1-1632890127049.png

Best Regards

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

Thanks yingyinr!
Helpt me alot, but i can't still get the visuals to work with filters, out of city, region, date and so on. Do i have to unpivot these columns as well?

Hi @Martenandersson ,

Please try to update the formula of measure [percent "No" of totals] as below and check whether it can be filtered correctly. You can find the details in the attachment.

percent "No" of totals =
VAR _numberofno =
CALCULATE (
COUNT ( 'Table'[Value] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Columns] = SELECTEDVALUE ( 'Table'[Columns] )
&& 'Table'[Value] = "No"
)
)
VAR _count =
CALCULATE (
COUNT ( 'Table'[Value] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Columns] = SELECTEDVALUE ( 'Table'[Columns] )
)
)
RETURN
DIVIDE ( IF ( ISBLANK ( _numberofno ), 0, _numberofno ), _count, 0 )

yingyinr_0-1632992578563.png

If the above one is not working, please provide some sample data included with region,date field and your expected result with backend logic and specific examples. Thank you.

Best Regards

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

Perfect Yinginr! 

It works just fine. Thanks alot!

 

Another question, if i today (september) get rank 1-4 is like "test 1, test 2 test 3 and test 4".  and want the same rank för last month and the month before to se a trend. How do i do that? Because if i filter by august, the results my be "test 8, test 9, test 10 and test 11", but i want the same as this month, and compare those "tests" 2 month back in time. 

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