Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Application Module ExternalTaskId TaskType CreateDate
LocalApp | Mod1 | 1 | 1 | 12/6/2016 12:01:00 PM |
LocalApp | Mod1 | 1 | 2 | 12/6/2016 12:09:00 PM |
NetApp | Mod2 | 1 | 1 | 12/6/2016 12:02:00 PM |
NetApp | Mod2 | 1 | 2 | 12/6/2016 12:08:00 PM |
LocalApp | Mod1 | 2 | 1 | 12/6/2016 12:05:00 PM |
LocalApp | Mod1 | 2 | 2 | 12/6/2016 12:06:00 PM |
I have data similar to the above table. I would like to get a TimeSpan difference for each of the "unique" start,end times. Currently I don't have the 1st two "distinct" from the bottom two (other than the time), if needed I can add that, so that each grouping of the two are unique.
Can I combine each Two Rows so that I can get a diff between (example row 1 & row 2) for CreateDate?
Solved! Go to Solution.
There are normally better or worse approaches depending on what you are trying to do. But that aside, you could do this in Power Query (get data).
Load the table
add an index column
create a custom column that is the index +1 (call it next)
save the query but don't load it
join the table to itself on the index = next column.
When done, delete all the columns you don't need, including the Index columns
Hi @joelv67,
I agree with MattAllingto's point of view, if you have a index column, you can directly use it to get the diff.
For example: "Tasktype" is the index column.
Diff(TaskType) = var currApplication= LASTNONBLANK(Sheet6[Application],[Application]) var diffSecond=DATEDIFF(MAXX( FILTER(ALL(Sheet6), Sheet6[Application]=currApplication&& Sheet6[ExternalTaskId]=MAX([ExternalTaskId])&& Sheet6[TaskType]<max([TaskType])),[CreateDate]), MAX([CreateDate]),SECOND) return if(diffSecond<> BLANK(),diffSecond,0)
If your records not contain the index column, you can use the date as the index.
Diff = var currApplication= LASTNONBLANK(Sheet6[Application],[Application]) var diffSecond=DATEDIFF(MAXX( FILTER(ALL(Sheet6), Sheet6[Application]=currApplication&& Sheet6[ExternalTaskId]=MAX([ExternalTaskId])&& Sheet6[CreateDate]<max([CreateDate])),[CreateDate]), MAX([CreateDate]),SECOND) return if(diffSecond<> BLANK(),diffSecond,0)
Result visual:
Regards,
Xiaoxin Sheng
Matt and Xiaoxin Sheng -
Thank you for your responses.
I was able to get Matt's solution to work.
My data sample was over simplified. I am not sure I can apply Xiaoxin Sheng's solution to my issue, but I will give it a try as well. The EventTypeId can not be the index and I don't think the CreateDate can as well, since multiple Application/Module combinations will be writing to the table and I am sure some Dates will collide.
But perhaps I can use the combination of creating an index column from Matt's suggestion with Xiaoxin Sheng's suggestion.
joelv
There are normally better or worse approaches depending on what you are trying to do. But that aside, you could do this in Power Query (get data).
Load the table
add an index column
create a custom column that is the index +1 (call it next)
save the query but don't load it
join the table to itself on the index = next column.
When done, delete all the columns you don't need, including the Index columns
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
72 | |
70 | |
37 | |
29 | |
26 |
User | Count |
---|---|
91 | |
49 | |
45 | |
38 | |
36 |