Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I am currently using the following DAX statement to calculate the difference between two dates.
Day Count of Drop = SWITCH(
TRUE(),
'KPI Dashboard AD'[Campaign Creation Date]<'KPI Dashboard AD'[Start Date], DATEDIFF('KPI Dashboard AD'[Campaign Creation Date],'KPI Dashboard AD'[Start Date],DAY),
'KPI Dashboard AD'[Start Date]>'KPI Dashboard AD'[Campaign Creation Date], DATEDIFF('KPI Dashboard AD'[Start Date],[Days Between Drop Creation and Start],DAY)*-1,
0
)
This seems to work, but there are two use cases that this statement doesn't account for:
Once the above use cases have been handled, I am looking to have a process that assigns the value to the calculation.
When "Error" show "Error" (Use Case #1 above)
When calc is "0" Very Urgent (Use Case #2 above)
When calc between "1" and "3" Urgent
When calc between "4" and "7" Standard
When calc is "8" or greater, Not Urgent
Appreciate the feedback on how to do this.
HI @Anonymous
Is this calculated column close?
Day Count of Drop =
VAR MyDateDiff = INT('KPI Dashboard AD'[Start Date]) - INT('KPI Dashboard AD'[Campaign Creation Date]) RETURN SWITCH( True(), MyDateDiff < 0 , "Error", MyDateDiff = 0 , "Very Urgent" , MyDateDiff < 4 , "Urgent" , MyDateDiff < 8 , "Standard" , "Not Urgent" )
Phil, this is awesome.
Can you help adjust my original statement so that the following works as a proper calc?
When Start Date = Create Date "0"
When Start Date is greater than Create Date = "Error"
Essentially, I will have tow columns in my table
1. The count of days between
2. The value which you addressed in your original post
Thanks!
HI @Anonymous
So just to clarify, you are after a column that shows the difference between your two dates in days - but if the value is negative you want to display "Error"?
That would mean mixing data types, so all your numbers would be text.
Have I understood correctly, or perhaps you could post a mock up (using excel) of what you would like the column to look like.
I'm just not sure what you mean by "proper calc"
Thanks for the clarification Phil. You understand it correctly, and I see the conflict in what I have asked for.
I would take the negative value with a calc. My statement does not address this condition.
That way I could differentiate between negative and true "0".
Sceondly, if you could help me understand your initial solution (which works great), that would help this newbie to not ask again. Teach a man to fish, if you know what I mean.
Thanks again.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
85 | |
66 | |
51 | |
45 |
User | Count |
---|---|
216 | |
89 | |
82 | |
66 | |
57 |