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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Kumshan450
Helper III
Helper III

Calculate difference between two date/time values using current row minus previous row

how to calculate the time difference between two consecutive rows (current row - previous row) in a Column data

 

COLLECTION DTM In sample data. 

 

Thereafter i want to check whether the difference in timing less than one minute. IF its less than one minute then 1 otherwise 0

 

Note: I have 20 lakh rows of data. I want a solution which will fit the data size.data sample.JPG

4 REPLIES 4
Phil_Seamark
Microsoft Employee
Microsoft Employee

HI @Kumshan450

 

If you add the following calculated column to your table, it will show the number of seconds between the current and previous row, which you can then use in an IF statement to 

 

Seconds Diff = 
VAR StateName = '2018'[State Name]
VAR BranchName = '2018'[Branch Name] 
VAR CurrentCollectionDTM = '2018'[Collection DTM]
VAR PreviousCollecitonDTM = 
            MAXX(
                    FILTER(
                        '2018',
                        '2018'[State Name] = StateName &&
                        '2018'[Branch Name] = BranchName && 
                        '2018'[Collection DTM] < CurrentCollectionDTM
                    ),
                    '2018'[Collection DTM]
                    )
RETURN IF( DATEDIFF(PreviousCollecitonDTM,CurrentCollectionDTM,SECOND)<60,1,0)                        
            

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hi, Its unable to handle large volume of data. Capture99990.JPG

How many rows in your data table?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

I have 20 lakh rows of data

Helpful resources

Announcements
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors