Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
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!