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
ooptennoort
Advocate I
Advocate I

Concat two Text.Length in if statement (combine text.length's of two columns if not equal)

Why do these give an error:

 

= Table.AddColumn(#"Changed Type, "COMPARE", each if[TEXT]<>[TEXT.1] then Text.Length([TEXT]) &" vs. "& Text.Length([TEXT.1]) else "=")

 

= Table.AddColumn(#"Changed Type, "COMPARE", each if[TEXT]<>[TEXT.1] then Text.Combine({Text.Length([TEXT]), Text.Length([TEXT.1])}, " vs. ") else "=")

 


= Table.AddColumn(#"Changed Type, "COMPARE", each if[TEXT]=[TEXT.1] then "=" else Text.Length([TEXT]) &" vs. "& Text.Length([TEXT.1]))

 

= Table.AddColumn(#"Changed Type, "COMPARE", each if[TEXT]=[TEXT.1] then "=" else Text.Combine({Text.Length([TEXT]), Text.Length([TEXT.1])}, " vs. "))

 

Alternatives? (I want to be able to "see" the diff between 2 text columns.)

1 ACCEPTED SOLUTION
Anonymous
Not applicable

it would have been easier to help you if you had written the error it gives you for each of the expressions.

For example, for the former, the problem could be that Power Query cannot concatenate numbers and text.

 

For this you should convert the numeir to text. Thus, for example:

 

= Table.AddColumn(#"Changed Type, "COMPARE", each if[TEXT]<>[TEXT.1] then Text.From(Text.Length([TEXT])) &" vs. "& Text.From(Text.Length([TEXT.1])) else "=")

 

...

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

it would have been easier to help you if you had written the error it gives you for each of the expressions.

For example, for the former, the problem could be that Power Query cannot concatenate numbers and text.

 

For this you should convert the numeir to text. Thus, for example:

 

= Table.AddColumn(#"Changed Type, "COMPARE", each if[TEXT]<>[TEXT.1] then Text.From(Text.Length([TEXT])) &" vs. "& Text.From(Text.Length([TEXT.1])) else "=")

 

...

 

You're right (of course)!! (Still learning)

Expression.Error: We cannot apply operator & to types Number and Text.

 

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.