Forum Discussion

itsmeanuj's avatar
itsmeanuj
Icon for Helper IV rankHelper IV
2 years ago
Solved

Cumulative total by year

Hi Guys,

 

I need to calculate the cumulative total of sales (& other metrics like projected sales, planned sales, etc ) which I need to show online and stacked column chart. I have a single select-year slicer at the top so the cumulative sum should be done for a year. e.g. Dec'22 should be the sum of Jan'22-Dec'22 sales and Jan'23 should only be Jan'23. Can someone please help me create a measure to achieve this?

 

Here is what my data looks like:

 

MONTHYearSales
2022-01-01202211
2022-02-01202222
2022-03-01202228
2022-04-01202237
2022-05-01202252
2022-06-01202261
2022-07-01202269
2022-08-01202279
2022-09-01202286
2022-10-012022115
2022-11-012022122
2022-12-012022143
2023-01-012023119
2023-02-01202390
2023-03-01202380

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi itsmeanuj ,

    If I understand correctly, the issue is that you cumulative total by year. Please try the following methods and check if they can solve your problem:

    1.Create the Table 2 and Data Table.

    2.Move the Table 2 month field to the slicer visual.

     

    3.Create a measure to cumulative totals.

    Measure = 
    CALCULATE(
        SUM('Table 2'[Sales]),
        FILTER(
            ALL('Data Table'),
            'Data Table'[Year] = MAX('Data Table'[Year])
            && 'Data Table'[MONTH] <= MAX('Data Table'[MONTH])
        )
    )

    4.Move the month to the stacked column chart X-axis and move the measure to the Y-axis.

     

    5.Select the Dec 22 and the result is shown below.

     

    Best Regards,

    Wisdom Wu

     

     

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi itsmeanuj ,

    If I understand correctly, the issue is that you cumulative total by year. Please try the following methods and check if they can solve your problem:

    1.Create the Table 2 and Data Table.

    2.Move the Table 2 month field to the slicer visual.

     

    3.Create a measure to cumulative totals.

    Measure = 
    CALCULATE(
        SUM('Table 2'[Sales]),
        FILTER(
            ALL('Data Table'),
            'Data Table'[Year] = MAX('Data Table'[Year])
            && 'Data Table'[MONTH] <= MAX('Data Table'[MONTH])
        )
    )

    4.Move the month to the stacked column chart X-axis and move the measure to the Y-axis.

     

    5.Select the Dec 22 and the result is shown below.

     

    Best Regards,

    Wisdom Wu

     

     

     

  • Please look into Quick Measures. They include templates for the Running Total calculation.