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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors