This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowJuly 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more
Hi Everyone,
I am not sure what is going on with the IF function but it is not working as I would expected to. I want to get the number of days between two dates if a certain condition is met. If the condition is not met I want it get me the number of days that have passed.
This is my current formula.
| Customer | Status | Return Date | Shipping Date | DateDiff |
| A | Closed | 1/28/2019 | 2/1/2019 | 4 |
| B | Active | 2/4/2019 | 4 | |
| C | Active | 4 | ||
| D | Active | 2/4/2019 | 4 |
How do I get it to output the correct value?
Note: When I take out the IF function and seperate the DATEDIFF functions the output is correct.
Solved! Go to Solution.
HI @amlopez45,
Can you please share pbix file for test? Your formula works well on my side.
Regards,
Xiaoxin Sheng
HI @amlopez45,
Can you please share pbix file for test? Your formula works well on my side.
Regards,
Xiaoxin Sheng
Hi @Anonymous,
The formula is working well now. I tried Collins method and it seemed to do the job. Not really sure what happened. Thank you for offering to help. ![]()
Hi Everyone,
I am not sure what is going on with the IF function but it is not working as I would expected to. I want to get the number of days between two dates if a certain condition is met. If the condition is not met I want it get me the number of days that have passed.
This is my current formula.
| Customer | Status | Return Date | Shipping Date | DateDiff |
| A | Closed | 1/28/2019 | 2/1/2019 | 4 |
| B | Active | 2/4/2019 | 4 | |
| C | Active | 4 | ||
| D | Active | 2/4/2019 | 4 |
How do I get it to output the correct value?
Note: When I take out the IF function and seperate the DATEDIFF functions the output is correct.
hello @amlopez45
first things first, try changing your data format (top of modeling tab) to date for your calculated column and see if that fixes your issue
here is a picture of what I did.
best regards,
Collin
Hello @Anonymous,
Thank you for the suggestion, the formula is working well now. ![]()
Great to hear, be sure to mark the post as the solution for anyone else that comes along.
best Regards,
Collin
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 25 | |
| 23 | |
| 19 | |
| 17 | |
| 14 |
| User | Count |
|---|---|
| 24 | |
| 23 | |
| 20 | |
| 20 | |
| 19 |