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
kkalyanrr
Helper V
Helper V

Reverse percent of Column total

Hello,

Can we get a reverse percent of Column total in the below table..I know its a little weird requirement 😞

kkalyanrr_1-1649332231851.png

Output should be 

NameOverallTestPercent column of total
A530.00%
B531.68%
C3210.06%
D2011.17%
E1817.88%
F329.61%
G029.61%
Total179100%
1 ACCEPTED SOLUTION

@AlexisOlson  - I have scenario where in I need to distribute a value across these 7 people..where in person with highest "Overalltest"  should get small chunk and lowest "Overalltest" should get big chunk.

Thanks.

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

This is annoyingly tricky since you need to tie-break the rankings.

 

My basic approach to this would be to define a ReverseName measure that returns the name from a reverse ranking and then use that in any measure that you want to calculate the "reverse" for.

 

ReverseName = 
VAR _Names = ALLSELECTED ( Table1[Name] )
VAR _NameCount = COUNTROWS ( _Names )
VAR _CurrName = SELECTEDVALUE ( Table1[Name] )
VAR _Ranks =
    ADDCOLUMNS (
        _Names,
        "@RankName", RANKX ( _Names, [Name],, ASC ),
        "@RankVal", RANKX ( _Names, CALCULATE ( SUM ( Table1[OverallTest] ) ) )
    )
VAR _AscDesc =
    ADDCOLUMNS (
        _Ranks,
        "@ASC",  RANKX ( _Ranks, _NameCount * [@RankVal] + [@RankName],, ASC ),
        "@DESC", RANKX ( _Ranks, _NameCount * [@RankVal] + [@RankName],, DESC )
    )
VAR _AscRank =
    MAXX ( FILTER ( _AscDesc, [Name] = _CurrName ), [@ASC] )
RETURN
    MAXX ( FILTER ( _AscDesc, [@DESC] = _AscRank ), [Name] )

 

Then PercentReverse can be defined as

PercentInverse =
VAR _Name = [ReverseName]
RETURN
    CALCULATE ( [Percent], Table1[Name] = _Name )

This should work for whatever measure you want to use instead of [Percent].

AlexisOlson
Super User
Super User

It should be possible but it would help if you can explain why you're trying to do this.

@AlexisOlson  - I have scenario where in I need to distribute a value across these 7 people..where in person with highest "Overalltest"  should get small chunk and lowest "Overalltest" should get big chunk.

Thanks.

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.