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
CoreyP
Solution Sage
Solution Sage

Cumulative Total by Index

Hi Everyone,

 

Hoping you can help me write a measure for cumulative running total, but by an Index column rather than a date. I would like a measure for cumulative total of the ONHAND QTY column in the attached image. Note, this table is filterable by Item No, so the returned dataset could have an index of 775-792, for example. Pick Sequence3.JPG

 

Thanks so much for your help! Note, ONHAND QTY is a column, but I can replace it with a measure if I need to.

1 ACCEPTED SOLUTION

Hi @CoreyP ,

 

This is a context problem, when you add the measure in your table since you have other columns within the visual and all of the fields belong to the same table the context changes so you need to apply the filter no only to the INDEX column but to all other columns in this case you need to redo your measure to:

 

Cumulative =
CALCULATE (
    SUM ( 'Pick sequence'[ONHAND_QTY] );
    FILTER (
        ALLSELECTED (
            'Pick sequence'[Pick Sequence];
            'Pick sequence'[PALLET_ID];
            'Pick sequence'[Item N.º]
        );
        'Pick sequence'[Pick Sequence] <= MAX ( 'Pick sequence'[Pick Sequence] )
    )
)

 

Check PBIX file attach I added a slicer for pallet s you can try to select different values and check that the cumulative still is calculated.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

15 REPLIES 15
BICrazy
Helper II
Helper II

Hi there community,

 

Hoping to get some guidance on my 3rd measure to calculate the Cumulative Total by index: 

In my first measure, I'm calculating Bank Submissions:

 

Bank Submissions = 
    DISTINCTCOUNTNOBLANK('Ongoing & Unpaid Data Revised'[Policy No#])

 


In my second measure, I'm calculating the Previous Index Churn:

 

Previous Index Churn = 
VAR CV = [Bank Submissions]
VAR D = SELECTEDVALUE( 'Ongoing & Unpaid Data Revised'[Index] ) - 1
VAR E = 
CV - CALCULATE(
    [Bank Submissions],
    'Ongoing & Unpaid Data Revised'[Index] = D && CV <> BLANK(),
    ALLSELECTED( 'Ongoing & Unpaid Data Revised'[Index] ))

RETURN
ABS(E)

 

 
Then  in my 3rd measure, I'm trying to get the Cumulative Churn:

 

Cumulative Churn = 

CALCULATE (
    [Previous Index Churn],
    FILTER (
        ALLSELECTED ( 'Ongoing & Unpaid Data Revised'[Index]),
            'Ongoing & Unpaid Data Revised'[Index] <= MAX('Ongoing & Unpaid Data Revised'[Index]
    )
))

 

 This is not giving me the desired results, but instead I'm just getting a repeat of the total:

image.png

 



Hi @BICrazy ,

 

Maybe you need to try the following measure:

Cumulative Churn =
SUMX (
    TOPN (
        MAX ( 'Ongoing & Unpaid Data Revised'[Index] ),
        SUMMARIZE (
            'Ongoing & Unpaid Data Revised',
            'Ongoing & Unpaid Data Revised'[Index],
            "PreviousChurn", [Previous Index Churn]
        )
    ),
    [PreviousChurn]
)

Be aware that without any data is difficult to know if this is the correct syntax.

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix ,

Thanks for the suggestion. This measure didn't get the cumulative totals.  This is what I got:

image.png

 

I'm basically looking to sum the Previous Index Churn e.g.
6982 + 5876 = 12858
12858 + 3664 = 16522
16522 + 2623 = 19145
19145 + 2203 = 21348  .....and so forth




Hi @BICrazy ,

 

Can you please send me a mockup?


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix  - sent you a pm with a link to onedrive, which contains the mockup

Hi @BICrazy ,

 

You should use the following measure:

Cumulative_Churn_1 = 
    SUMX (
        FILTER (
            SUMMARIZE (
                ALL ( 'Ongoing & Unpaid Data Revised'[Index] ),
                'Ongoing & Unpaid Data Revised'[Index],
                "@IndexChurn", [Previous Index Churn]
            ),
            'Ongoing & Unpaid Data Revised'[Index]
                <= MAX ( 'Ongoing & Unpaid Data Revised'[Index] )
        ),
        [@IndexChurn]
    )

MFelix_0-1622468161383.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix ,

This works like a charm.  Just that the 29517 on Index 0 is the base.  I'd like to start the count from Index 1 onwards. 

Hi @BICrazy ,

 

Should the first value be 6982 or 36499?

 

If you want to have the 6.982 then use the measure:

 

Cumulative_Churn_ > 0 = 
    SUMX (
        FILTER (
            SUMMARIZE (
                ALL ( 'Ongoing & Unpaid Data Revised'[Index] ),
                'Ongoing & Unpaid Data Revised'[Index],
                "@IndexChurn", [Previous Index Churn]
            ),
            'Ongoing & Unpaid Data Revised'[Index]
                <= MAX ( 'Ongoing & Unpaid Data Revised'[Index] ) && 'Ongoing & Unpaid Data Revised'[Index] > 0
        ),
        [@IndexChurn]
    )

 

If you don't want the 0 but want the basis sum use the following:

Cumulative_Churn wthout 0 = 
    IF( MAX('Ongoing & Unpaid Data Revised'[Index]) <> 0, SUMX (
        FILTER (
            SUMMARIZE (
                ALL ( 'Ongoing & Unpaid Data Revised'[Index] ),
                'Ongoing & Unpaid Data Revised'[Index],
                "@IndexChurn", [Previous Index Churn]
            ),
            'Ongoing & Unpaid Data Revised'[Index]
                <= MAX ( 'Ongoing & Unpaid Data Revised'[Index] ) 
        ),
        [@IndexChurn]
    ))

 

MFelix_0-1622472306981.png

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix 

Starting value is 6982.  Thanks so much for your help.  This is exactly what I was looking for.  Much appreciated.

MFelix
Super User
Super User

Hi @CoreyP

You need to do a similar measure to this:

Cumulative =
CALCULATE (
SUM ( TABLE[ONHAND QTY] );
FILTER ( ALLSELECTED ( TABLE[INDEX] ); TABLE[INDEX] <= MAX ( TABLE[INDEX] ) )
)

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



This measure simply returns the same value.

 
Cumulative =
CALCULATE (
SUM ( 'Pick Sequence'[ONHAND_QTY] ),
FILTER ( ALLSELECTED ('Pick Sequence'[Pick Sequence] ), 'Pick Sequence'[Pick Sequence] <= MAX ( 'Pick Sequence'[Pick Sequence] )
))
Pick Sequence4.JPG

Hi @CoreyP ,

 

This is a context problem, when you add the measure in your table since you have other columns within the visual and all of the fields belong to the same table the context changes so you need to apply the filter no only to the INDEX column but to all other columns in this case you need to redo your measure to:

 

Cumulative =
CALCULATE (
    SUM ( 'Pick sequence'[ONHAND_QTY] );
    FILTER (
        ALLSELECTED (
            'Pick sequence'[Pick Sequence];
            'Pick sequence'[PALLET_ID];
            'Pick sequence'[Item N.º]
        );
        'Pick sequence'[Pick Sequence] <= MAX ( 'Pick sequence'[Pick Sequence] )
    )
)

 

Check PBIX file attach I added a slicer for pallet s you can try to select different values and check that the cumulative still is calculated.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @CoreyP ,

 

Try the following change in the code:

Cumulative =
CALCULATE (
SUM ( 'Pick Sequence'[ONHAND_QTY] ),
FILTER ( ALL ('Pick Sequence'[Pick Sequence] ), 'Pick Sequence'[Pick Sequence] <= MAX ( 'Pick Sequence'[Pick Sequence] )
))

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Unfortunately, that does not work either.

 

I've kinda all but given up. I keep googling and re-writing and re-googling and re-googlewriting and now I just think it's a tad too advanced. Or, what's probably more likely, I'm not advanced enough to write it. 

Hi,

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.