cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
kitcatnj
Frequent Visitor

New Column With Nested IFs

I am analyzing a column and based on what's in there, adding a new column. There are 3 things to check for.

Does the column contain "??",  NULL, and anything not = to 2 char in length

 

This part works. 

-Checking for nulls and ??

= Table.AddColumn(STAGING_workorder, "siteRefGB", each if Text.Contains([siteref], "??") then "BAD" else if [siteref] = null then "BAD" else "GOOD")


Once i add the check for length to the query, it fails. 
IF(LEN ([siteref]) <> 2 then "bad" ) 

 

BUT... If i do a check on ONLY the length, that works. I can't combine them

 

Any help would be appreciated!

1 ACCEPTED SOLUTION
AilleryO
Memorable Member
Memorable Member

Hi,

I (think you missed the M function you need 😉

LEN doesn't exist in M , but Text.Length does 🙂

more info : https://learn.microsoft.com/en-us/powerquery-m/text-length

Hope it helps

View solution in original post

2 REPLIES 2
kitcatnj
Frequent Visitor

THANK YOU !!!! That was it! This now works. 

= Table.AddColumn(TABLENAME "siteRefGB", each if Text.Contains([siteref], "??") then "BAD" else if [siteref] = null then "BAD" else if Text.Length([siteref]) <> 2 then "BAD" else "GOOD")

AilleryO
Memorable Member
Memorable Member

Hi,

I (think you missed the M function you need 😉

LEN doesn't exist in M , but Text.Length does 🙂

more info : https://learn.microsoft.com/en-us/powerquery-m/text-length

Hope it helps

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors