Forum Discussion

dyee4613v1's avatar
dyee4613v1
Frequent Visitor
1 year ago
Solved

Flexible Month Calculation

Hi.  I'm trying to do MTD/YTD/YTD LY calculations and the calculations need to be flexible based on a month filter.  Here is how I wanted to do it.   1. YTD = CALCULATE(Sum(GL[AMOUNT]),'Invoked Fun...
  • MasonMA's avatar
    1 year ago

    dyee4613v1 


    Hi, if your Date table is already properly marked as a Date table in Power BI I'd suggest using time intelligence function instead of comparing the date text. 

    So for your MTD it would be 

    MTD =
    VAR MaxSelectedDate = MAX('Invoked Function'[Date])
    RETURN
    CALCULATE(
    SUM(GL[AMOUNT]),
    DATESMTD('Invoked Function'[Date]),
    'Invoked Function'[Date] <= MaxSelectedDate
    )