Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I am very new to power bi and dax, learning as I go.
I am trying to use an if statement that checks a date added column and compares it to 2 hard coded dates, if it is between the dates I want to display "P3" and if not then display "NA" in a new column. I have this code:
Solved! Go to Solution.
@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!
@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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 37 | |
| 33 | |
| 33 | |
| 29 |
| User | Count |
|---|---|
| 134 | |
| 96 | |
| 78 | |
| 67 | |
| 65 |