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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Sayonip
Frequent Visitor

Comparing Two Excels in Power BI

Hello,

I have 2 excels with employee details for previous and current month. I need to find the employees who left, new joiners, and any employee for whom the other columns are changed except for Age as Age will change for all employees every month.

I am attaching two dummy excels. Please help me with a power query or a DAX formula to compare both the excels to create reports on a monthly basis. I have a large dataset so it is becoming difficult to compare. I tried merging current data with previous data in BI but the number of left employees are not matching with the count of employees. I have followed some videos in YoutTube (https://youtu.be/294BH6vOpcs?feature=shared) but unable to clear the issue. I also tried solutions posted in similar questions in the community but couldnt solve. Any help is appreciated.
Thanks in advance
 
Current month data
IDTypeDepComCCFTELastFirstTitleAge
85PGA 1OrIaMarketing43
856PGAG1deMeCFO21
77TGSSA0.9BeNiLocal66
331PEAG1AlElTechnical32
323P A 0BsErLead Engineer50
319PGASA1DeAlDirector 45
315PGSCO1ItGeSupervisor46
311PEASA1LeLoCoordinator25
307P S 0.3MaGoCoordinator28
303P R 0NiGoPurchase21
299TERPM1ScRoManager28
295P R 0.7SeAnEngineer26
291PERSA1ZaIsGlobal28
243TERSA0.7BoElLocal43
307P S 0.6MaGoRep28
287PERCO1BaRoTechnical37
283PERPM1FaIoPurchase41
279P R 0RoGhLead Engineer43
275PERCO1EvOsDirector 45
271PERPM0.8SiOnLead Engineer47
267P S 0CeIoCoordinator49
263P R 0RoAnCoordinator51
259PERPM1DeAnManager53
255PERG0.75AyIaPurchase55
251TERSA1BoGoManager57
247TERG1LiNoEngineer59
243TGRSA0.3BoElGlobal43
239TERPM1CaLoTechnical63
227TGDSA1ScRtDirector 65
223TGDTS1DeAnSupervisor67
219PGDR0.5ChIcCoordinator69
215PGSR1EtNiPurchase71
211PGDTS0.6RoGoManager73
207PGDTS1WeErEngineer75
 
Previous month data
IDTypeDepComCCFTELastFirstTitleAge
85PGA 1OrIaMarketing43
856PGAG1deMeCFO21
77PGASA1BeNiGlobal66
331PEASA1AlElTechnical32
327PEAPUR1ArGePurchase43
323P A 0BoErLead Engineer50
319PGASA1DeAlDirector 45
315PESCO1ItGeSupervisor46
311PESSA1LeLoCoordinator25
307P S 0.3MaGoManager28
303P R 0NiGoPurchase21
299PERPM1ScRoManager28
295P R 0.7SeAnEngineer26
291PERSA1ZaIsGlobal28
243TERSA0.7BoElLocal43
307P S 0.6MaGoRep28
287PERCO1BaRoTechnical37
283PERPM1FaIoPurchase41
279P R 0RoGoLead Engineer43
275PERCO1EvOsDirector 45
271PERPM1SuOnSupervisor47
267P R 0CeIoCoordinator49
263P R 0RoAnCoordinator51
259PERPM1DeAnManager53
255PERG0.75AyIaPurchase55
251TERCO1BoGoManager57
247TERG1LiNoEngineer59
243TERSA0.3BoElGlobal43
239TERPM1CaLoTechnical63
235TEDG1MoNaPurchase44
231TGDG0.3ScNdLead Engineer53
227TGDSA1ScRtDirector 65
223TGDTS1DeAnSupervisor67
219PGDR0.5ChIcCoordinator69
215PGDR1EvNePurchase71
211PGDTS1RoGoManager73
207PGDCO1WeErEngineer75
 
 
2 ACCEPTED SOLUTIONS
AmiraBedh
Super User
Super User

 

You need to merge the 2 files.

Merge CurrentMonth with PreviousMonth on the ID column, using a left outer join. This will help identify new joiners and employees who have changes.

Repeat the merging step, this time merging PreviousMonth with CurrentMonth on the ID column to identify employees who left.

 

Use a conditional column in Power Query in the 1st Merge and the same logic for your 2nd merge :

 
= Table.AddColumn(#"Expanded PreviousMonthData", "Custom", each if [PreviousMonthData.ID] = null then "New Joiner" else null)

 

Employees who left := Table.AddColumn(#"Expanded CurrentMonth", "Custom", each if [CurrentMonth.ID] = null then "Left" else null) 

 

Then in your 1st merge to get employees with changes :

 

= Table.AddColumn(#"Added Custom", "Custom.1", each if [Type] <> [PreviousMonthData.Type] or [Dep] <> [PreviousMonthData.Dep] or [Com] <> [PreviousMonthData.Com] or [CC] <> [PreviousMonthData.CC] or [FTE] <> [PreviousMonthData.FTE] or [Last] <> [PreviousMonthData.Last] or [First] <> [PreviousMonthData.First] or [Title] <> [PreviousMonthData.Title] then "Changed" else null)

 

I attached the pbix file with all the steps.

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

Anonymous
Not applicable

Hi, @Sayonip 

 

Considering the large dataset you're talking about, try using measure. You can try the following methods.

left employees = Var _table=EXCEPT(VALUES('Previous month data'[ID]),VALUES('Current month data'[ID]))
 RETURN
 IF(SELECTEDVALUE('Previous month data'[ID]) in _table,1,0)
new joiners = Var _table=EXCEPT(VALUES('Current month data'[ID]),VALUES('Previous month data'[ID]))
 RETURN
 IF(SELECTEDVALUE('Current month data'[ID]) in _table,1,0)

vzhangtinmsft_0-1730083426903.png

Type change = 
VAR _Prevtype=CALCULATE(MAX('Previous month data'[Type]),FILTER(ALL('Previous month data'),[ID]=SELECTEDVALUE('Current month data'[ID])))
RETURN
IF(SELECTEDVALUE('Current month data'[Type])<>_Prevtype,1,0)
Dep change = 
VAR _PrevDep=CALCULATE(MAX('Previous month data'[Dep]),FILTER(ALL('Previous month data'),[ID]=SELECTEDVALUE('Current month data'[ID])))
RETURN
IF(SELECTEDVALUE('Current month data'[Dep])<>_PrevDep,1,0)

And so on, the result is:

vzhangtinmsft_1-1730083587466.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi, @Sayonip 

 

Considering the large dataset you're talking about, try using measure. You can try the following methods.

left employees = Var _table=EXCEPT(VALUES('Previous month data'[ID]),VALUES('Current month data'[ID]))
 RETURN
 IF(SELECTEDVALUE('Previous month data'[ID]) in _table,1,0)
new joiners = Var _table=EXCEPT(VALUES('Current month data'[ID]),VALUES('Previous month data'[ID]))
 RETURN
 IF(SELECTEDVALUE('Current month data'[ID]) in _table,1,0)

vzhangtinmsft_0-1730083426903.png

Type change = 
VAR _Prevtype=CALCULATE(MAX('Previous month data'[Type]),FILTER(ALL('Previous month data'),[ID]=SELECTEDVALUE('Current month data'[ID])))
RETURN
IF(SELECTEDVALUE('Current month data'[Type])<>_Prevtype,1,0)
Dep change = 
VAR _PrevDep=CALCULATE(MAX('Previous month data'[Dep]),FILTER(ALL('Previous month data'),[ID]=SELECTEDVALUE('Current month data'[ID])))
RETURN
IF(SELECTEDVALUE('Current month data'[Dep])<>_PrevDep,1,0)

And so on, the result is:

vzhangtinmsft_1-1730083587466.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

AmiraBedh
Super User
Super User

 

You need to merge the 2 files.

Merge CurrentMonth with PreviousMonth on the ID column, using a left outer join. This will help identify new joiners and employees who have changes.

Repeat the merging step, this time merging PreviousMonth with CurrentMonth on the ID column to identify employees who left.

 

Use a conditional column in Power Query in the 1st Merge and the same logic for your 2nd merge :

 
= Table.AddColumn(#"Expanded PreviousMonthData", "Custom", each if [PreviousMonthData.ID] = null then "New Joiner" else null)

 

Employees who left := Table.AddColumn(#"Expanded CurrentMonth", "Custom", each if [CurrentMonth.ID] = null then "Left" else null) 

 

Then in your 1st merge to get employees with changes :

 

= Table.AddColumn(#"Added Custom", "Custom.1", each if [Type] <> [PreviousMonthData.Type] or [Dep] <> [PreviousMonthData.Dep] or [Com] <> [PreviousMonthData.Com] or [CC] <> [PreviousMonthData.CC] or [FTE] <> [PreviousMonthData.FTE] or [Last] <> [PreviousMonthData.Last] or [First] <> [PreviousMonthData.First] or [Title] <> [PreviousMonthData.Title] then "Changed" else null)

 

I attached the pbix file with all the steps.

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.