Forum Discussion

AThakur1's avatar
AThakur1
Frequent Visitor
1 year ago
Solved

Issue with TotalMTD Calculation.

Hi, I am trying to calcuate MTD Consumption & using below dax.    MTDConsumption = TOTALMTD(SUM(Consumption[Qty Consumed]),Consumption[Consumption Date])   In below image selected item was last ...
  • v-echaithra's avatar
    1 year ago

    Hi AThakur1 ,

    Try the below DAX,

    MTD Consumption =
    var_CurrentMonth = MONTH(TODAY())
    var_CurrentYear = YEAR(TODAY())
    var_Hasdatathismonth =
    CALCULATE(COUNTROWS(Consumption),
    FILTER(
    Consumption,
    MONTH(Consumption[Consumption Date]) = _CurrentMonth &&
    YEAR(Consumption[Consumption Date]) = _CurrentYear
    )
    ) > 0
    RETURN
    IF(Hasdatathismonth, TOTALMTD(SUM(Consumption[Qty Consumed]), 'Date'[Date]),BLANK()
    It checks if the item has any consumption in April, and only then it shows MTD otherwise shows blank.

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

    Thanks and Regards,
    Chaithra E.