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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Table.SelectColumns error

I am using Power Query Editor's Custom Column window to attempt the following;

I have Table1 and Table2. I am trying to add a custom column to Table1, that contains Table2 as the value, but only if a value is not null in Table1.

 

 

This code works, it places the table in the new custom column. But it does not include my condition.

 

= Table.SelectColumns(#"Table2", {"Column1", "Column2"})

 

Result = Table2 as a table, with the values within

 

 

This is with the condition added, the result of this code is a null table as the value if [ValueFromThisTable] is not null. Why did it change to a null table when the above code puts in the right table?

 

= if [ValueFromThisTable] = null then null else 
Table.SelectColumns(#"Table2", {"Column1", "Column2"})

 

Result = if the value is null, null. Otherwise, Table2Name as table, with null within

 

 

If someone could please explain to me where I have gone wrong, and why this is happening, I would appreceate it. Thanks

1 ACCEPTED SOLUTION
jbwtp
Memorable Member
Memorable Member

Hi @Anonymous,

 

Assuming that your example is in th econtext of Table.AddColumn() the behaviour is quite weird.

Do you want to try to split the formula to something like:

t2 = Table.SelectColumns(#"Table2", {"Column1", "Column2"}),
t1 = Table.AddColumn(..., ..., each if [ValueFromThisTable] = null then null else t2)

and see if this works Ok?

 

Thanks,

John

View solution in original post

2 REPLIES 2
jbwtp
Memorable Member
Memorable Member

Hi @Anonymous,

 

Assuming that your example is in th econtext of Table.AddColumn() the behaviour is quite weird.

Do you want to try to split the formula to something like:

t2 = Table.SelectColumns(#"Table2", {"Column1", "Column2"}),
t1 = Table.AddColumn(..., ..., each if [ValueFromThisTable] = null then null else t2)

and see if this works Ok?

 

Thanks,

John

Anonymous
Not applicable

Well it turns out I just needed to refresh Power Query Editor, the values have always been there they just were showing null. Found this out after trying your version and multiple variations of each step, one by one until it broke. It always broke once I clicked to view one of the tables to validate the data however an expansion of the table reveals its all there. 

 

Very odd

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.