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