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
Anonymous
Not applicable

Dynamic pareto table

I hope that you are in for a treat... a brain squeezing treat! 

I want to make a pareto curve that can adjust itself based on selected Country. 

I have the following data:

CountryCompany MembersUnits
V-CH14425320104
V-DK1374353094
V-DK1264918085
V-D1003821174
V-F1022837769
V-I94845164
V-DK1418902163
V-CH1044010161
V-DK1268125961
V-D1006897654
V-CH1330389050
V-CH1042940845
V-DK1264472843
V-D1004496742
V-I94846542
V-D1003902139
V-CH1043332238
V-DK1327311136
V-DK1264917936
V-A1044656036
V-I94852136


I would like to visualize a table that shows: 1) Rank, 2) Cumulative Total, and 3) Cumulative Total %.

CountryCompany MembersUnitsRankCumulativeCumulative %
V-CH1442532010411041,0%
V-DK137435309421982,0%
V-DK126491808532832,8%
V-D100382117443573,6%
V-F102283776954264,2%
V-I9484516464904,9%
V-DK141890216375535,5%
V-CH104401016186146,1%
V-DK126812596196756,7%
V-D1006897654107297,3%
V-CH1330389050117797,8%
V-CH1042940845128248,2%
V-DK1264472843138678,6%
V-D1004496742149099,1%
V-I94846542159519,5%
V-D1003902139169909,9%
V-CH104333223817102810,2%
V-DK132731113618106410,6%
V-DK126491793619110011,0%
V-A104465603620113611,3%
V-I9485213621117211,7%


In addition, users wish to have the ability to filter on country e.g. If they filter on "V-DK" (Denmark), they wish to have the following result:

CountryCompany MembersUnitsRankTotalCumulativeCumulative %
V-DK137435309411108948,5%
V-DK12649180852110817916,2%
V-DK14189021633110824221,8%
V-DK12681259614110830327,3%
V-DK12644728435110834631,2%
V-DK13273111366110838234,5%
V-DK12649179367110841837,7%



Can anyone help me on how to acheive this in PowerBI? 🙂 

Kind Regards
Martin

2 ACCEPTED SOLUTIONS

Add a small random number to your values to break the ties.

View solution in original post

PaulDBrown
Community Champion
Community Champion

Great solution @lbendlin ! Hadn't thought of that!

Ok so following this great idea, create the following:

Add a new column to the fact  table with the following:

random.JPG

and then:

Unit temp = [Sum Units] +  SUM(FactTable[Random])
RNK Temp = RANKX(ALLSELECTED(FactTable), [Unit temp],,DESC,Dense)
Cumulative =
VAR RNK = [RNK Temp]
RETURN
    IF (
        ISBLANK ( [Sum Units] ),
        BLANK (),
        IF (
            ISINSCOPE ( 'Dim Country'[DCountry] ),
            CALCULATE (
                [Unit temp],
                FILTER ( ALLSELECTED ( FactTable ), [RNK Temp] <= RNK )
            )
        )
    )
% Cumul = 
VAR _Total = CALCULATE([Unit temp], ALLSELECTED(FactTable))
RETURN
DIVIDE([Cumulative], _Total)

You can decide what to display in the visual. I've kept the original [Sum Units] and [Rank] measures.

new result.JPG

 

 

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

8 REPLIES 8
PaulDBrown
Community Champion
Community Champion

Great solution @lbendlin ! Hadn't thought of that!

Ok so following this great idea, create the following:

Add a new column to the fact  table with the following:

random.JPG

and then:

Unit temp = [Sum Units] +  SUM(FactTable[Random])
RNK Temp = RANKX(ALLSELECTED(FactTable), [Unit temp],,DESC,Dense)
Cumulative =
VAR RNK = [RNK Temp]
RETURN
    IF (
        ISBLANK ( [Sum Units] ),
        BLANK (),
        IF (
            ISINSCOPE ( 'Dim Country'[DCountry] ),
            CALCULATE (
                [Unit temp],
                FILTER ( ALLSELECTED ( FactTable ), [RNK Temp] <= RNK )
            )
        )
    )
% Cumul = 
VAR _Total = CALCULATE([Unit temp], ALLSELECTED(FactTable))
RETURN
DIVIDE([Cumulative], _Total)

You can decide what to display in the visual. I've kept the original [Sum Units] and [Rank] measures.

new result.JPG

 

 

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Thank you so much for your help @PaulDBrown, and not at least @lbendlin

I am sending you a welldeserved highfive from Denmark

 

Kind regards
Martin

PaulDBrown
Community Champion
Community Champion

With this model:

model.JPG

and the following measures:

Sum Units = SUM(FactTable[Units])
Rank =
IF (
    ISBLANK ( [Sum Units] ),
    BLANK (),
    IF (
        ISINSCOPE ( 'Dim Country'[DCountry] ),
        RANKX ( ALLSELECTED ( FactTable ), [Sum Units],, DESC, DENSE )
    )
)

 

Cumulative =
VAR RNK = [Rank]
RETURN
    CALCULATE ( [Sum Units], FILTER ( ALLSELECTED ( FactTable ), [Rank] <= RNK ) )
% Cumul =
VAR _Total =
    CALCULATE ( [Sum Units], ALLSELECTED ( FactTable ) )
RETURN
    DIVIDE ( [Cumulative], _Total )

 

You will get:

RankCountry.gif

 

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Hi @PaulDBrown 

Thank you so much for your feedback! Your solution is very close to what I need 😄 

I notice that your "Rank", "Cumulative total" and "Cumulative %" does not count values that aren't unique. E.g. when filtering on Denmark, there are 2 "company members" that have sold 36 units, and your rank subsequently provides them with the same value, which also affects your "cumulative total" and "Cumulative %"

Do you have an easy fix for this issue? 😄

Kind regards
Martin

Add a small random number to your values to break the ties.

Well, if they have the same value, they have the same rank!





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






lbendlin
Super User
Super User

@Anonymous I don't understand your Cumulative Total % column examples - shouldn't they end up at 100% for each last row?

Anonymous
Not applicable

Hi @lbendlin , 

 

you are totalt right and sorry for the confusion. I thought I could add the Excel calculation as documentation, but was instead forced to copy a part of it. 

nevertheles, do you know how it can be solved? 😃

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.