Forum Discussion

as3znaus's avatar
as3znaus
Helper I
9 years ago
Solved

Cumulative SUM by CODE

Hi Everyone,

 

How can I create a "Coste Actual Estimado" column that shows an accumulated value, something like this:

 

 Coste Mensual EstimadoCoste Total 2015Coste Actual Estimado
Month05050
January05050
February05050
March05050
April05050
May05050
June05050
July155065
August105075
September155090
October 05090
November 3550125
December4050165

 

In addition, I have to disinguish the values by CODE (cause I have a lot of projects).

 

Thanks

  • Hi as3znaus,

     

    Based on the sample data above, you can create "Coste Actual Estimado" column using below formula. But, you should add an index column in Query Editor.

     

    Coste Actual Estimado =
    CALCULATE (
        SUM ( 'Cumulative SUM'[Coste Mensual Estimado] ),
        FILTER (
            'Cumulative SUM',
            'Cumulative SUM'[Index] <= EARLIER ( 'Cumulative SUM'[Index] )
        )
    )
        + 'Cumulative SUM'[Coste Total 2015]

     

    What do you mean "disinguish the values by CODE"? Is "CODE" a column in your source table? For further analysis, would you please share some more sample data and describe more detailed about "CODE"?

     

    Thanks,
    Yuliana Gu

4 Replies

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi as3znaus,

     

    Based on the sample data above, you can create "Coste Actual Estimado" column using below formula. But, you should add an index column in Query Editor.

     

    Coste Actual Estimado =
    CALCULATE (
        SUM ( 'Cumulative SUM'[Coste Mensual Estimado] ),
        FILTER (
            'Cumulative SUM',
            'Cumulative SUM'[Index] <= EARLIER ( 'Cumulative SUM'[Index] )
        )
    )
        + 'Cumulative SUM'[Coste Total 2015]

     

    What do you mean "disinguish the values by CODE"? Is "CODE" a column in your source table? For further analysis, would you please share some more sample data and describe more detailed about "CODE"?

     

    Thanks,
    Yuliana Gu

  • Baskar's avatar
    Baskar
    Resident Rockstar

    1. Create one index column for this in Query editor with what sorting u want.

     

    2. Create column 

     

    Column = var index_1 = index

    var sum_of_Coste_Mensual_Estimado = calculate ( sum(Coste Mensual Estimado), filter (all(Table_Name), index < index_1 )

    var Val_Coste_Total_2015 = 'Coste Total 2015'

     

     

    return Val_Coste_Total_2015 + sum_of_Coste_Mensual_Estimado

     

     

    Try this , I hope it will help u dude, 

     

    let me know if it is not helping u

    • as3znaus's avatar
      as3znaus
      Helper I

      Thanks for the answers! I finally managed to avoid this sum using Group By.

       

       

      • Baskar's avatar
        Baskar
        Resident Rockstar

        I srtongly recomemded to everyone to avoid Earlier because it will create performance issue.

         

        check with large amount of data.