Forum Discussion

rbowen's avatar
rbowen
Helper III
2 years ago
Solved

Using Greater Than And Less Than With IF Statment

I'm trying to create a calculated column in my Date table for fiscal year based on the CalendarDate column. Here's what I'm after:

 

If the calendar date is greater than or equal 09/01/2022 and less than or equal to 08/31/2023, the result should be 2023. Otherwise, the result should be 2024.  My date table only has dates that encompass both fiscal years 09/01/2022 to 08/31/2024 so anything that isn't 2023 should automatically be 2024. The DAX I'm using is this:

 

FiscalYear = IF('Dates'[CalendarDate] >= 09/01/2022 && 'Dates'[CalendarDate] <= 08/31/2023, "2023", "2024")
 
However, it gives a value of 2024 for every date in the date table instead of the appropriate breakout. I've tried various permutations of this dax statment but either errors or complete blanks. I'm obviously missing some crucial bit of syntax but at a loss to figure out what's going on. What am I missing?

 

  • rbowen Try:

    FiscalYear = IF('Dates'[CalendarDate] >= DATE(2022,9,1) && 'Dates'[CalendarDate] <= DATE(2023,8,31), "2023", "2024")

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    rbowen Try:

    FiscalYear = IF('Dates'[CalendarDate] >= DATE(2022,9,1) && 'Dates'[CalendarDate] <= DATE(2023,8,31), "2023", "2024")