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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
gzai
Frequent Visitor

Match 2 tables and replace all values in first table

Hi,

 

I have 2 tables as follows : 

 

tracking

-------------

Agency   Estimate   Media   Remarks   Cost   Invoice   Invoice Date   Billable AR   Billable AP   
ABC   P.123456   R123   R_12_A   0     00
ABC   P.123456   R124   R_12_B   120     00
BCD   P.123457   R125   R_13_A   0     00

 

outstanding

-------------

Agency   Estimate   Media   Remarks   Cost   Invoice   Invoice Date   Billable AR   Billable AP   
ABC   P.123456   R124   R_12_B   120   1234567890   2024-01-01   1200

 

If outstanding table contains data with same column values for "agency", "estimate", "media", "remarks" and "costs" compare it with tracking table with same columns, then data in tracking table will be updated based on latest data from outstanding table, only values in "invoice", "invoice date", "billable AR" and "billable AP" columns will be updated.

 

expected results : 

 

tracking

-------------

Agency   Estimate   Media   Remarks   Cost   Invoice   Invoice Date   Billable AR   Billable AP   
ABC   P.123456   R123   R_12_A   0  00
ABC   P.123456   R124   R_12_B   1201234567890   2024-01-01   1200
BCD   P.123457   R125   R_13_A   0  00

 

Any help would be appreciated. 

 

Thanks in advance !

2 ACCEPTED SOLUTIONS
gzai
Frequent Visitor

I've found the answer,

 

1. using merger queries LeftOuter ( tracking table as first table, and outstanding as second table )

2. expand desired columns from outstanding table in tracking table

3. using replace value on desired column if from column expansion has a value

 

I don't know if there is another quick way, but this is the only way I found.

View solution in original post

Hi @gzai ,
There is another way to accomplish this:
1.Click append queries,

vheqmsft_0-1708408660016.png

2.Remove duplicate rows

vheqmsft_1-1708408739239.png

3.Final output

vheqmsft_2-1708408779175.png

 

Best regards,

Albert He

 

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
gzai
Frequent Visitor

I've found the answer,

 

1. using merger queries LeftOuter ( tracking table as first table, and outstanding as second table )

2. expand desired columns from outstanding table in tracking table

3. using replace value on desired column if from column expansion has a value

 

I don't know if there is another quick way, but this is the only way I found.

Hi @gzai ,
There is another way to accomplish this:
1.Click append queries,

vheqmsft_0-1708408660016.png

2.Remove duplicate rows

vheqmsft_1-1708408739239.png

3.Final output

vheqmsft_2-1708408779175.png

 

Best regards,

Albert He

 

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.