Forum Discussion

AlexEners's avatar
AlexEners
Frequent Visitor
8 years ago
Solved

Sum add all the previous elements to a date

Hi, imagine there is a table with two column: Date and count code. (date show italian month)

 

This is a table result from a graph. My query have all code in a date.

What i need is a table/graph that sum all previous code to a date; For example july 2017 (in the table "luglio 2017") will have the number of June 2017 + July 2017 (in table "giugno 2017"  + "luglio 2017") so 240+668= 908.
So something like that:
giugno 2017      |   240
luglio 2017        |   908
agosto 2017      |   908+220
settembre 2017 |  908+220+248


How can i do this?

  • AlexEners,

    You want a running total (cummulative total).

    Check the link below how to do it,

    https://whatthetechisthat.wordpress.com/2017/05/30/power-bi-cumulative-totals/

     

    If your date field in below table is a date heirarchy, then you can choose only month and year. You need to have a calendar table and establish relatship with your data table.

     

     Running Toal Measure =

          CALCULATE(

              Sum(Table[Value],

              FILTER(All(Dim_Date[Date]), Dim_Date[Date] <= MAX(Dim_Date[Date]

              )

            )

4 Replies

  • anandav's avatar
    anandav
    Icon for Skilled Sharer rankSkilled Sharer

    AlexEners,

    You want a running total (cummulative total).

    Check the link below how to do it,

    https://whatthetechisthat.wordpress.com/2017/05/30/power-bi-cumulative-totals/

     

    If your date field in below table is a date heirarchy, then you can choose only month and year. You need to have a calendar table and establish relatship with your data table.

     

     Running Toal Measure =

          CALCULATE(

              Sum(Table[Value],

              FILTER(All(Dim_Date[Date]), Dim_Date[Date] <= MAX(Dim_Date[Date]

              )

            )

      • Anonymous's avatar
        Anonymous
        Not applicable

        AlexEners,

        Yes. You are able to calculate running total using anandav's DAX in DirectQuery mode. Ensure that  you turn on "allow unrestricted measures in directquery mode" option in your Power BI Desktop.



        Regards,
        Lydia

  • Hi AlexEners

     

    Here what I would do : 

    1 - Create a new calculated colum to get your month name. 

     

    MonthName = YourTable[DataInzoFornituraMese].[Mese]

     

    (Not sure about the spelling as i'm trying to write this formula in italian)

     

    2 - Use this month name + Sum of Conteggio di CodidePOD in a visual.

     

    - Quentin