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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
pye
Helper I
Helper I

Replace value from another table exclude null

Hi there!

 

I have table 1 here with some incorrect data and would like to replace it based on the table 2.

The value in red font is wrong, the correct data is in 2nd table.

pye_1-1685601015663.png

 

 

with the code below, I manage to replace the red wrong value in Table 1 with Table 2:

Table.FromRecords(Table.TransformRows(#"Table1",each _&(Table2{[year=[year],id=[id]]}? ??[])))

 

However, is it possible if can only replace those not null (exclude the grey cells in Table 2)? In table 1, row 3, energyusage.value of 600 is correct, so it is null in table 2 (grey cell), no need to replace null to table 1. How do with only replace the value in Table 2 to Table 1 if it contains a value, not replace if Table 2 is empty?

 

Thank you

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

wdx223_Daniel_0-1685602349133.png

 

= Table.FromRecords(Table.TransformRows(Table1,each let a=Table2{[Year=[Year],ID=[ID]]}? in if a is null then _ else Record.TransformFields(_,Table.ToList(Table.SelectRows(Record.ToTable(a),each [Value]<>null and [Value]<>""),each {_{0},(x)=>_{1}}),1)))

View solution in original post

2 REPLIES 2
pye
Helper I
Helper I

works well which null is not replacing the value! thank you!

wdx223_Daniel
Super User
Super User

wdx223_Daniel_0-1685602349133.png

 

= Table.FromRecords(Table.TransformRows(Table1,each let a=Table2{[Year=[Year],ID=[ID]]}? in if a is null then _ else Record.TransformFields(_,Table.ToList(Table.SelectRows(Record.ToTable(a),each [Value]<>null and [Value]<>""),each {_{0},(x)=>_{1}}),1)))

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.