Forum Discussion

edson_souza's avatar
edson_souza
Regular Visitor
8 years ago
Solved

DAX Formula Accumulate only the current month

I have historical values and need a measure to accumulate values only for the current month dynamically via DAX. How do I do?   I have: Date Value 19/09/2018 300,00 20/09/2018 781,00 21/09/2018...
  • edson_souza's avatar
    8 years ago

    Hi, Anonymous and v-yulgu-msft. 

     

    I solved by mingling your help.

    1) I created the calendar;
    2) I created a measure to load only values of the current month:

    Value Current Month = 
    CALCULATE(
        SUM('Fact'[Value]); 
        FILTER('Calendar';MONTH('Calendar'[Dates]) = MONTH(TODAY())); 
        FILTER('Calendar';YEAR('Calendar'[Dates]) = YEAR(TODAY()))
        )

    3) And then I used DATESMTD in the created measure:

    Value Current month MTD = 
    CALCULATE(
        [Value Current Month];
        DATESMTD(Calendar[Dates])
       )

     

     https://imgur.com/a/oV2j2Wj

     

    Thank you very much.