Forum Discussion

CoreyP's avatar
CoreyP
Solution Sage
6 years ago
Solved

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. 

 

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

  • 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.

15 Replies

  • 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] ) )
    )
    • CoreyP's avatar
      CoreyP
      Solution Sage

      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] )
      ))
      • MFelix's avatar
        MFelix
        Super User

        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] )
        ))

         

         

  • 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:

     



    • MFelix's avatar
      MFelix
      Super User

      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.

       

      • BICrazy's avatar
        BICrazy
        Helper II

        Hi MFelix ,

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

         

        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