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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
mattchunghk
Regular Visitor

Distribution of Values by Cumulative Percentage, Highest to Lowest.

Please Help!
My power BI

mattchunghk_0-1688395584171.png

I want to make this : 

 

Capture.PNG

 

My code:

 

Cumulative Percentage = 
// Define variables
VAR SelectedSeason = "58 SS23"
VAR CurrentProductClass = SELECTEDVALUE('Ordered Lines'[Product Class])
VAR CurrentAccountNumber = SELECTEDVALUE('Ordered Lines'[Account Number])
VAR CurrentItemCode = SELECTEDVALUE('Ordered Lines'[Item Code and Colour])

// Calculate the total GBP for the selected product class and account number
VAR TotalGBPbyProductAndAccount =
    CALCULATE(
        SUM('Ordered Lines'[GBP]),
        'Ordered Lines'[Order Season] = SelectedSeason,
        'Ordered Lines'[Product Class] = CurrentProductClass,
        'Ordered Lines'[Account Number] = CurrentAccountNumber
    )

VAR ItemsWithHigherOrEqualTotalGBP =
    FILTER(
        ALLSELECTED('Ordered Lines'[Item Code and Colour]),
        CALCULATE(
            SUM('Ordered Lines'[GBP]),
            'Ordered Lines'[Order Season] = SelectedSeason,
            'Ordered Lines'[Product Class] = CurrentProductClass,
            'Ordered Lines'[Account Number] = CurrentAccountNumber,
            'Ordered Lines'[Item Code and Colour] = EARLIER('Ordered Lines'[Item Code and Colour])
        ) >= CALCULATE(
            SUM('Ordered Lines'[GBP]),
            'Ordered Lines'[Order Season] = SelectedSeason,
            'Ordered Lines'[Product Class] = CurrentProductClass,
            'Ordered Lines'[Account Number] = CurrentAccountNumber,
            'Ordered Lines'[Item Code and Colour] = CurrentItemCode
        )
    )

VAR CumulativeGBPbyItemCode =
    CALCULATE(
        SUM('Ordered Lines'[GBP]),
        'Ordered Lines'[Order Season] = SelectedSeason,
        'Ordered Lines'[Product Class] = CurrentProductClass,
        'Ordered Lines'[Account Number] = CurrentAccountNumber,
        'Ordered Lines'[Item Code and Colour] IN ItemsWithHigherOrEqualTotalGBP,
        ALLSELECTED('Ordered Lines'[Item Code and Colour])
    )

// Return the Cumulative Percentage by dividing Cumulative GBP by Total GBP
RETURN DIVIDE(CumulativeGBPbyItemCode, TotalGBPbyProductAndAccount)

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @mattchunghk ,

 

It is recommended to create a new calculation table like this:

vcgaomsft_0-1688527790197.png

We need [CumulativeGBPbyItemCode] for sort.

vcgaomsft_1-1688527876910.png

vcgaomsft_2-1688527897981.png

Please check the pbix file.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @mattchunghk ,

 

It is recommended to create a new calculation table like this:

vcgaomsft_0-1688527790197.png

We need [CumulativeGBPbyItemCode] for sort.

vcgaomsft_1-1688527876910.png

vcgaomsft_2-1688527897981.png

Please check the pbix file.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.