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
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
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