Forum Discussion

Mani_ms's avatar
Mani_ms
Helper I
6 years ago
Solved

Calculate total not matching with Max function

Hi ,   I have table by country and quantity with month category. I am bringing YTD quantity based on Max Function if current month equal to Max and  i want to return until previous month YTD quant...
  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    6 years ago

    Hi Mani_ms ,

     

    Do you want to calculate the cumulative value when the month is equal to today's month, the other months show the value of the current month?

    For example, when the month name is Aug, it will calculate the cumulative value.

     

     

    If yes, you can use the following measure.

     

    Measure = 
    var _YTD = CALCULATE(SUM('Table'[quantity]),FILTER(ALLEXCEPT('Table','Table'[Country]),'Table'[Month number]<=MAX('Table'[Month number])))
    var _currentmonth = FORMAT(TODAY(),"mmm")
    var _sum = SUM('Table'[quantity])
    return
    IF(
        MAX('Table'[Month name])=_currentmonth,_YTD,_sum)

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

     

    Best regards,

     

    Community Support Team _ zhenbw

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    BTW, pbix as attached.