Forum Discussion
Datediff Formula question
- 4 years ago
I see you wanted to do is to calculate for those rows created date is before 7/31/2020 and resolved date is blank or after 7/31/2020.
For the rows, you want to adjust the resolved date blank as the cut off date "7/31/2020".
Tryout 2 Open Age = IF ( -- only those rows with created date <= 7/31/2020 and resolved date as blank or after 7/31/2020 ('FreshService RAW DATA'[Created Date] <= Date(2020,7,31) && ( IsBlank('FreshService RAW DATA'[Resolved Date] || 'FreshService RAW DATA'[Resolved Date] > Date(2020,7,31) ) ), DATEDIFF( 'FreshService RAW DATA'[Created Date], IF ( IsBlank('FreshService RAW DATA'[Resolved Date] ), Date(2020,7,31), 'FreshService RAW DATA'[Resolved Date] ) , DAY) )
Your formula works great when there is a reolved date. The issue is when there is no resolved date. I want it to calculate from Created date to the date I input like 12/31/2021. In excel I am easly able to that that but not power bi.
This formula works great except for the last part.
Mar 19 Open Age = If(AND('FreshService RAW DATA'[Created Date]<=Date(2019,3,31),'FreshService RAW DATA'[Resolved Date]>Date(2019,3,31)),DATEDIFF('FreshService RAW DATA'[Created Date],DATE(2019,3,31),Day))
Hi Anonymous ,
There are some calculation logic differences between powerbi and excel. In powerbi, each calculation column needs to be formed by creating a separate formula. It is not like excel where you can form multiple columns based on the same calculation logic.
If you want to display it in the way shown in the screenshot, you can only do so by creating separate calculated columns.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.