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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Bruno_M
Frequent Visitor

How to compare value from conscutives rows and only for a same value ?

Hi everyone,

 

I am facing a problem with a new report I am working on and hope to find some help oer some ideas here 😊

 

My source is an excel file and the data is about employee data :

Each time a person is hired, a new line is created in the Excel file, mentionning, among other informations 

- the start date

- the end date

- and an employee ID

 

A same person can be mentioned several time (vacation work for example).

 

Once my file is imported, I sort it by employee code, then by date, and get something like that :

 

Bruno_M_0-1692909331232.png

 

 

What I am trying to do :

if the employee ID is the same, I would like to compare the 'start date' of the underneath row against the 'end date' of the row above.

 

In example given I would like to compare :

A2 vs nothing

A3 vs B2 (A3>B2)

A4 vs B3 (A4>B3)

A5 vs B4 (A5>B4)

A6 vs B5 (A6>B5)

A7 vs nothing (new Employee ID)

A8 vs B7 (A8>B7)

A9 vs B8 (A9>B8)

A10 vs nothing (new Employee ID)


and so on

 

I thought, as a first step, about grouping my data on the Employee ID column and then indexing it, but actualy, I dont know if it the right thing to do or what could be the next steps 😅

 

Thank you for you help !

 

Regards

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
Bruno_M
Frequent Visitor

HI @amitchandak,

I thank you for your help and for your time 😊

Unfortunately, the way you told me didn't work : it worked for some of the rows but some of them didn't get the right value.

I manage to solve my problem adding a row number by group (group based on the Employee ID) and then using the EARLIER function that I didn't knew about.

 

Regards

 

View solution in original post

2 REPLIES 2
Bruno_M
Frequent Visitor

HI @amitchandak,

I thank you for your help and for your time 😊

Unfortunately, the way you told me didn't work : it worked for some of the rows but some of them didn't get the right value.

I manage to solve my problem adding a row number by group (group based on the Employee ID) and then using the EARLIER function that I didn't knew about.

 

Regards

 

amitchandak
Super User
Super User

@Bruno_M , check if this can help

https://community.powerbi.com/t5/Community-Blog/Power-BI-Continuous-Streak-With-One-Day-Break/ba-p/1...

 

To get end date of last row for same employee you can use

a new column =

var _max = maxx(filter(Table, [Employee ID] = earlier( [Employee ID]) && [End Date] < earlier( [End Date] )), [End Date] )

return

if([Start Date] > [End Date], 1, 0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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