Forum Discussion
Check if a date column is between 2 hard coded dates
- 1 year ago
Jkrupski Try:
columnTest = VAR dateAdded = [column] VAR P3Start = DATE(2025,3,29) VAR P3End = DATE(2025,3,29) RETURN If(dateAdded <= P3End && dateAdded >= P3Start, "P3", "NA")FORMAT turns dates into text and that is not a good way to compare dates.
Hi Jkrupski ,
Thanks for the reply from Greg_Deckler .
There is something wrong with your start date and end date, they are both March 29, 2025, and P3 is returned only when the date is equal to March 29, 2025, and NA is returned for other dates.
Modify your syntax, something like the code below:
columnTest =
VAR dateAdd = 'Table'[column]
VAR P3Start = DATE(2025, 3, 4)
VAR P3End = DATE(2025, 3, 29)
RETURN
IF(
dateAdd>= P3Start && dateAdd <= P3End,
"P3",
"NA"
)
The final visual effect is shown below:
The pbix file is attached.
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!