Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Difference between two consecutive rows according to the filters applied in the matrix

Hello Power Bi Experts,

 

I am new to Power Bi and I need your help and achieving a certain outcome.

 

Here is the sample data-

User NameActivity TypeDatetime
user1Data Accepted Successfully10-04-2021 15:20
user2Data Accepted Successfully09-04-2021 10:39
user3Data Accepted Successfully09-04-2021 09:40
user4Master Data Saved Succesfully!05-04-2021 18:03
user5Data Got Rejected24-03-2021 16:27
user6Data Accepted Successfully24-03-2021 10:09
user6Master Data Saved Succesfully!19-03-2021 19:14

 

I need the time taken for each activity type. For example, data accepted successfully at 24-03-2021 10:09 after it got saved at 19-03-2021 19:14, so i need to find (24-03-2021 10:09)-(19-03-2021 19:14).

 

Here is the desired output-

User NameActivity TypeDatetimeTime Taken
user1Data Accepted Successfully10-04-2021 15:201.1950463
user2Data Accepted Successfully09-04-2021 10:390.0404051
user3Data Accepted Successfully09-04-2021 09:403.6513426
user4Master Data Saved Succesfully!05-04-2021 18:0312.0661
user5Data Got Rejected24-03-2021 16:270.2625347
user6Data Accepted Successfully24-03-2021 10:094.6217824
user6Master Data Saved Succesfully!19-03-2021 19:14 

 

Thanks in advance!

@amitchandak @Jihwan_Kim @Gordonlilj @Greg_Deckler 

1 ACCEPTED SOLUTION

@Anonymous , try a measure like

 

new measure =
var _max = maxx(filter(allselected(Table), [Datetime] < max([Datetime])),[Datetime])
return
datediff([datetime], _max, second)/(3600*24)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , Create a new column like

new column =
var _max = maxx(filter(Table, [Datetime] < earlier([Datetime])),[Datetime])
return
datediff([datetime], _max, second)/(3600*24)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak Thank You for your response. 

 

However, this solution doesn't give the desired result as the data is changing according to selection on matrix. Can we write any measure to get the output?

@Anonymous , try a measure like

 

new measure =
var _max = maxx(filter(allselected(Table), [Datetime] < max([Datetime])),[Datetime])
return
datediff([datetime], _max, second)/(3600*24)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak Thanks this works. 

can you please check your messages? 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.