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
Syndicate_Admin
Administrator
Administrator

CUMULATIVE SUM. BY CATEGORY

Hello. Can you help me please. I have not been able to make this measure.

I have this table:

I have a few price ranges and some brands.

I have a distinctive count on each brand to know how many materials it has.

I need to pull out a cumulative measure that adds up the materials as the price range increases.

CaroCM_27_0-1681054633123.png

The idea is that this measure will serve me for the whole and for %.

CaroCM_27_1-1681054828664.png

Please help me. All the solutions I have found are for dates. But this price range field is a text, not a date.

Thank you.

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

You will need to add an [Index] column to the PowerQuery editor to assist in [PUNTO DE PRECIO] sorting.

vcgaomsft_0-1681176960981.png

Sort one column by another column in Power BI

 

Then please create a new measure.

Measure = 
VAR _cumulative_count =
    SUMX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] <= MAX ( 'Table'[Index] ) ),
        [@MARCA 1]
    )
VAR _total_count =
    SUMX ( ALL ( 'Table' ), [@MARCA 1] )
VAR _result =
    DIVIDE ( _cumulative_count, _total_count )
RETURN
    _result

vcgaomsft_1-1681177527853.png

 

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

4 REPLIES 4
v-cgao-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

You will need to add an [Index] column to the PowerQuery editor to assist in [PUNTO DE PRECIO] sorting.

vcgaomsft_0-1681176960981.png

Sort one column by another column in Power BI

 

Then please create a new measure.

Measure = 
VAR _cumulative_count =
    SUMX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] <= MAX ( 'Table'[Index] ) ),
        [@MARCA 1]
    )
VAR _total_count =
    SUMX ( ALL ( 'Table' ), [@MARCA 1] )
VAR _result =
    DIVIDE ( _cumulative_count, _total_count )
RETURN
    _result

vcgaomsft_1-1681177527853.png

 

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

miTutorials
Super User
Super User

You can use Window() function to achieve this. Hope this detailed tutorial helps.

 

Cumulative Sales/Running Total for a Category with Window() Function in PowerBI | MiTutorials - YouT...

Hello. Thanks a lot.

Try to do it but don't succeed. fails to extract the accumulated measure in units and %.

try all combinations of 0-1 and ABS-REL but fail. I didn't accumulate.

But try another measure... I share it at the end.

CaroCM_27_0-1681177130363.png

But try two other measures and succeed. I share them:

Part 1 =
COUNTX(FILTER(ALLSELECTED(Consolidated),Consolidated[PRICE RANGE]<=.MAX(Consolidated[PRICE RANGE])),[COUNTER MATERIALS BRANDS])
CaroCM_27_2-1681177331151.png

and for the cumulative %

Cumulative measure =
where _1=COUNTX(FILTER(ALLSELECTED(Consolidated),Consolidated[PRICE RANGE]<=.MAX(Consolidated[PRICE RANGE])),[COUNTER MATERIALS BRANDS])
where _2=COUNTX(ALLSELECTED(Consolidated),[COUNTER MATERIALS BRANDS])
return
DIVIDE(_1,_2)

CaroCM_27_3-1681177455636.png

PijushRoy
Super User
Super User

Hi 

The requirement is not clear. What is the calculation for 6%, 7%, 11% so on
Could you please provide pbix file with sample data and calculation you need.

Thanks 
Pijush

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.