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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ClemFandango
Advocate II
Advocate II

Merge two columns into one column based on two condition

Hi there,

I am hoping someone can help me with a conditional column that I have created in Power Query. I have the following table (called This Month) and I am trying to combine the first two columns and create the conditional column.

 

The logic is that the ConditionalColumn = Active.a column, however if Active.a column = null then the ConditionalColumn = Inactive.b column.

 

Please see my example below:-

This Month

Table1 (Active a).AC Cust Num     Table1 (Inactive b).AC Cust Num     ConditionalColumn     
555
545
null33
nullnullnull
null11

 

I have used the following in the ConditionalColumn:-

 

= Table.AddColumn(#"Removed Duplicates1", "Custom.2", each if Text.From([[#"Table1 (Active a).AC Cust Num"]])<> null then [#"Table1 (Active a).AC Cust Num"]
else if Text.From([[#"Table1 (Active a).AC Cust Num"]])= null then [#"Table1 (Inactive b).AC Cust Num"]
else "")

 

 

However this results in the error message ‘We cannot convert a value of type Record to type Text’. All columns are currently formatted as text as it may include alphanumeric characters in the future.

 

Any ideas on how I can merge the values from two columns into one will be greatfully received!

 

Many thanks

 

CF

 

 

1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

Hi @ClemFandango,

 

When dealing with null (the absense of a value) you can use coalesce (??), to illustrate:

 

Table.AddColumn(#"Replaced Value", "Custom", each [#"Table1 (Active a).AC Cust Num"] ?? [#"Table1 (Inactive b).AC Cust Num"])

 

The error you reported is most likely due to the double set of square brackets within your syntax.

View solution in original post

2 REPLIES 2
m_dekorte
Super User
Super User

Hi @ClemFandango,

 

When dealing with null (the absense of a value) you can use coalesce (??), to illustrate:

 

Table.AddColumn(#"Replaced Value", "Custom", each [#"Table1 (Active a).AC Cust Num"] ?? [#"Table1 (Inactive b).AC Cust Num"])

 

The error you reported is most likely due to the double set of square brackets within your syntax.

Amazing - @m_dekorte you are my hero!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.