Forum Discussion
Difference in date between two columns in a measure?
- 3 years ago
Donny620 you can add a measure like this:
Trimmed Aging = VAR __Date1 = COALESCE ( SELECTEDVALUE ( Table[Date1] ), Table[Date2] ) VAR __Date2 = SELECTEDVALUE ( Table[Date2] ) VAR __Diff = DATEDIFF ( __Date1, __Date2, DAYS ) RETURN IF ( __Diff < 5, 5, IF ( __Diff > 540, 540, __Diff ) )
parry2k Thank you again! I'm having trouble duplicating the formula (Do I add another SelectedValue function and change 'Days' to 'Day'?) To make it super simple here are two files one an Excel which gives the
'answer' using the required logic and a pivot table, and one PBI which looks at the Excel and tries a formula like yours.
https://drive.google.com/file/d/1rRqD-bkrzi7TG2ioG_VpmeUZd_gM35wc/view?usp=drive_link
Thank you!!
You could always just use the Power Query through the 'Transform Data' Tab, if you had some thing like this:
The you could use a custom column to achieve what you want:
if [Date] = null and [Date2] <> null then [Date2] else if [Date] <> null and [Date2] = null then [Date] else if [Date] = null and [Date2] = null then null else List.Max({[Date],[Date2]}) - #duration(0,0,0,(Duration.TotalSeconds([Date]-[Date2]))/2)- Anonymous3 years agoNot applicable
- Donny6203 years ago
Helper I
Hi Anonymous thank you for your answer! Unforuntatly I for some reason can't add columns, only measures (and if I try to go to Transform Data I get "A DirectQuery connection is required"). Due to how the PBI is set up within my org. Is this task impossible if I can't create columns? Is there a measure that will work? Thanks!