YTD with current filter on Year Month

Hello
I have a filter by month-year.
My first measure will have to calculate the total costs by the current month selected. The second measure will have to calculate the cumulated total from the beginning of the year to the current month.

The problem is that the Total costs YTD measure is giving the same result as the Total Costs of the Current month. I tried using this formula to calculate YTD but still getting the same results
Quantité Réalisé YTD =
CALCULATE([TotalCosts];
DATESYTD(DIM_TPS_DATE[F_DATE]))

Am I missing something?

Thanks

@Fiona,

It’s a bit hard to diagnose the problem without seeing the PBIX file, but this sounds like an evaluation context problem. Try this - on a new page in your report with no slicers or page filters except Year = 2020, create two card visuals, one with your YTD measure (which looks fine to me) and one with the following measure, which creates the necessary context within the measure using variables and DATESBETWEEN. If both numbers come out right, then look to the slicer interaction or the context of your visual as the problem.

Total Costs Current Month = 

VAR CurrentMonth = MONTH( TODAY() )
VAR CurrentYear = YEAR( TODAY() )
VAR LastDayMonth = EOMONTH( TODAY(), 0 )
VAR StartDate = DATE( CurrentYear, CurrentMonth, 1 )
VAR EndDate = DATE( CurrentYear, CurrentMonth, LastDayMonth )

RETURN
CALCULATE(
    [Total Costs],
    DATESBETWEEN(
        Dates[Date],
        StartDate,
        EndDate
    )
)

Hope this is helpful. If you still have questions after trying this, please post your PBIX file and I’m sure we can figure out the problem.

Hi @BrianJ
Thanks for the troubleshooting steps I’ll test and report back.

Cheers
Fiona