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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors