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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Humanoidhuman
Frequent Visitor

Create percentage card for top 10 sum of column

Hi,

 

Background: I am new to using power BI. I have imported a dataset from excel which contains a value for which I have managed to get a sum of. One of my cards displays the sum and another one I have used basic filtering to display the top 10 within the sum of the values in that column.

 

Problem: I want to create a card which would display the the amount of the top 10 values from the total in percentage. An added layer is that the sum of the column for the top 10 is calculated based on another column [see example below]. The solutions that I found generally relate to scenarios where a new measure is created based on existing columns, but none based on filtered values within the column (top 10).

 

Example Table: I have something similar to a table metnioned below for a little more clarity regarding my concern. Basically my issue is to do caluclations on column C.

Name [A]Worked Hours [B]Overtime Hours [C]
Jack124
Jill102
Joann135
Jack91
Joe157
Joann2012
Jay8

0

Joann9

1

 

Anticipated Solution: I want a card in my dashboard which will display the top 10 from my calculated sum of values in percentage form. 

 

TIA!

1 ACCEPTED SOLUTION

Hi @Humanoidhuman 

 

Please try this:

I create a calculate column:

percentage =
VAR _SumOTH =
    SUMX ( ALL ( 'Table' ), 'Table'[Overtime Hours] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Overtime Hours] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Name] = EARLIER ( 'Table'[Name] ) )
    ) / _SumOTH

This return the percentage of the overtime of every person:

vzhengdxumsft_0-1710837834001.png

 

Then add a sort column:

Sort =
RANKX (
    'Table',
    SUMX (
        FILTER ( ALL ( 'Table' ), 'Table'[Name] = EARLIER ( 'Table'[Name] ) ),
        'Table'[Overtime Hours]
    ),
    ,
    DESC,
    DENSE
)

Finally, the top 3 column can be like:

Top3 =
SUMX ( FILTER ( 'Table', 'Table'[Sort] <= 3 ), 'Table'[Overtime Hours] )
    / SUM ( 'Table'[Overtime Hours] )

The result is as follow:

vzhengdxumsft_1-1710837945062.png

Best Regards

Zhengdong Xu
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-zhengdxu-msft
Community Support
Community Support

Hi @Humanoidhuman 

 

Could you please explain the logic of the percentage?

Although I read your post over and over again, I can't understand what is your expected overcome. 

vzhengdxumsft_0-1710380436306.png

 

Best Regards

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

I apologize if I was not clear. So for example, the total overtime hours in the above example table would be 31, and the total overtime hours for would be 5, which would be 16% of the total overtime hours. 
As of now, I am able to get to the number 5, but not able to convert it into percentage.

To put it in perspective, my card in my BI is filtered out to diplay the total overtime hours of the top 3 people with the most overtime hours. I have been able to use the TopN filter to display that (which shows the total number of OT hours) but I want it to be displayed as a percentage. Like for the above example, it would be 25 hours, but I would like it to be displayed as 80.64%.

I hope this makes more sense. 

Hi @Humanoidhuman 

 

Please try this:

I create a calculate column:

percentage =
VAR _SumOTH =
    SUMX ( ALL ( 'Table' ), 'Table'[Overtime Hours] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Overtime Hours] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Name] = EARLIER ( 'Table'[Name] ) )
    ) / _SumOTH

This return the percentage of the overtime of every person:

vzhengdxumsft_0-1710837834001.png

 

Then add a sort column:

Sort =
RANKX (
    'Table',
    SUMX (
        FILTER ( ALL ( 'Table' ), 'Table'[Name] = EARLIER ( 'Table'[Name] ) ),
        'Table'[Overtime Hours]
    ),
    ,
    DESC,
    DENSE
)

Finally, the top 3 column can be like:

Top3 =
SUMX ( FILTER ( 'Table', 'Table'[Sort] <= 3 ), 'Table'[Overtime Hours] )
    / SUM ( 'Table'[Overtime Hours] )

The result is as follow:

vzhengdxumsft_1-1710837945062.png

Best Regards

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

@v-zhengdxu-msft This worked for me thank you very much. Although I would like to extend the result into displaying the 'total' percentage of the top 3. For now I have used th ebasic sum function for that. Also I marked your answer as the solution in case anyone else is trying to do something similar. 

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.