IF date apply value

Hi guys, attempting to apply a value only if year is 2019, if my shipdate is = 2019 apply one value, if not another value.

Total Costs + 25% =

Var YearToday =YEAR(2019)


If(YearToday,[Total Costs]+ [Total Costs]*0.25,[Total Costs])

Hi Tyronne,

There are probably a few ways to resolve this but it all depends on what you need…
But first please check the result for your YearToday in a card or table visual:

You’ll see that this doesn’t actually return the year 2019. You can check the documentation here: https://docs.microsoft.com/en-us/dax/year-function-dax

If you use the Dates[Date] in a table you could do something like:

Total Costs + 25% = 
VAR YearToday = YEAR( DATE( 2019, 1, 1 ) )
VAR TotalCosts = [Costs]

IF( YEAR( MAX(Dates[Date]) ) = YearToday,
     TotalCosts + TotalCosts *0,25 ,

Say your YearToday alway needs to be the current year then you can change it into YEAR ( TODAY() )

1 Like

Thanks very helpful

What I have noticed when you select a year from the slicer it still applies the 0.25 for example to 2018 even though its should only apply to any value in 2019… any thoughts

Thanks very helpful

Managed to figure out this

Total Costs + 25% = if(CALCULATE([Total Costs],Dates[Year]>=“2019”),[Total Costs]+ ([Total Costs]*0.25),[Total Costs])