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

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

Reply
Amardeep100115
Post Prodigy
Post Prodigy

Conditional merging two tables with New rows

Hi All, 

 

 

i wish to perform conditional merging on one or two columns, i have give samle data in which i Table 1 and table 2 there and also Output result . 

 

i want to merge two table on basis of ID Column and get a count of Emp. if employee has not used assigned ID then that merging row would show zero and next row it should show which id he has used and number of time  he used 

 

Sample data 

 

Please help me with same in power query (M-code) or DAX  but mostly M-code Please 

Please share same in Power BI file. or in attached excel sheet also work for me 

Amardeep Bhingardeve
2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Amardeep100115 

 

You can try the following methodsYou need to add an index column to Power Query first.

vzhangti_0-1680851945454.png

Dax New Table:

Table = 
Var _Table1=SUMMARIZE(Table1,Table1[ID],Table1[Emp Name],Table1[Index],"Type","Emp")
Var _Table2=SUMMARIZE(Table2,Table2[ID],Table2[Emp Name],Table2[Index],"Type","Guest")
Return
UNION(_Table1,_Table2)

vzhangti_2-1680852034382.png

Column:

Emp Name2 = CALCULATE(MAX(Table1[Emp Name]),FILTER(Table1,[ID]=EARLIER('Table'[ID])))

vzhangti_1-1680852014808.png

Can you explain the logic of the other 2 columns?

 

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.

Hi @v-zhangti 

Please find the data that i am using, Please help me with merging table with Green tab data. Merge Visit data with Custmoer data and try to achive sample result data.  Please help me with m-code. 

Please let me know if you have any queirs 
New Sample data 


Amardeep Bhingardeve

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.