Forum Discussion

Kolumam's avatar
Kolumam
Icon for Post Prodigy rankPost Prodigy
6 years ago
Solved

Cumulative total until the selected month

I need to calculate the cumulative total until the selected month. Below is my table.

MonthSizeCumulative Size
Jan-196953
Feb-1963116
Mar-1985201
Apr-1963264
May-1962326
Jun-1996422
Jul-1977499
Aug-1984583
Sep-1962645
Oct-1983728
Nov-1953781
Dec-1984865

 

Expected Output:

When I use a filter for Month and select Sep-19, I should get the below:

MonthSizeCumulative Size
Jan-195253
Feb-1974127
Mar-1965192
Apr-1989281
May-1994375
Jun-1950425
Jul-1994519
Aug-1995614
Sep-19100714
  • hi Kolumam 

    For your case, you must use a spreated Month tables as the slicer

    Dim Month = VALUES('Table'[Month])

    Then use this measure in your visual.

    Measure = IF(MAX('Table'[Month])<=MAX('Dim Month'[Month]),CALCULATE(SUM('Table'[Size]),FILTER(ALLSELECTED('Table'),'Table'[Month]<=MAX('Table'[Month]))))

    By the way, you could set visual level filter is not blank

    Result:

    and here is sample pbix file, please try it.

    Regards,

    Lin

3 Replies

  • v-lili6-msft's avatar
    v-lili6-msft
    Icon for Community Support rankCommunity Support

    hi Kolumam 

    For your case, you must use a spreated Month tables as the slicer

    Dim Month = VALUES('Table'[Month])

    Then use this measure in your visual.

    Measure = IF(MAX('Table'[Month])<=MAX('Dim Month'[Month]),CALCULATE(SUM('Table'[Size]),FILTER(ALLSELECTED('Table'),'Table'[Month]<=MAX('Table'[Month]))))

    By the way, you could set visual level filter is not blank

    Result:

    and here is sample pbix file, please try it.

    Regards,

    Lin

  • In this situation, I have date table and Sales table to ralated with date column. So, the DAX will be like this

    Cumulative Qty =
    IF (
        MIN ( 'Date'[Date] ) <= CALCULATE ( MAX ( Sales[Order Date] )ALL ( Sales ) ),
        CALCULATE (
            SUM ( Sales[Quantity] ),
            FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
        )

     

    Hope this help.
    )