Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I need to calculate the datedifference between two dates in the same column. I cant seem to find an answer for this and would like to learn how to do this in PowerBi instead of excel.
Where the event type is 1, I need a new column at the end that finds the next time the same ResourceID has the EventType of 0
Ive looked at doing a datediff with the end date using a filter with calculate but cant seem to get this to work in any way. I think I just need to wrap my head around this to get my head out of Excel ways and into PowerBi.
Solved! Go to Solution.
try this
Column = -- first get the event type, resource and time of the current rows event Var eventType = 'Table'[EventType] var rID = 'Table'[ResourceID] var cur = 'Table'[EventTime]
-- calculate the min date for the table when resource is equal to the current resource, the event is 0 and its greater than the current date var nextevent = CALCULATE(min('Table'[EventTime]),all('Table'),'Table'[ResourceID] = rid, 'Table'[EventTime] > cur, 'Table'[EventType] = 0)
--apply the value to oonly event type 1 Var ret = if(eventType = 0 , blank(), nextevent)
-- return the value return ret
example
Proud to be a Super User!
try this
Column = -- first get the event type, resource and time of the current rows event Var eventType = 'Table'[EventType] var rID = 'Table'[ResourceID] var cur = 'Table'[EventTime]
-- calculate the min date for the table when resource is equal to the current resource, the event is 0 and its greater than the current date var nextevent = CALCULATE(min('Table'[EventTime]),all('Table'),'Table'[ResourceID] = rid, 'Table'[EventTime] > cur, 'Table'[EventType] = 0)
--apply the value to oonly event type 1 Var ret = if(eventType = 0 , blank(), nextevent)
-- return the value return ret
example
Proud to be a Super User!
Excellent works perfectly and i've figured out how it works too, didnt realise you could do so much in a column. Thank you for your help!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
99 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
110 | |
91 | |
84 | |
66 |