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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
aallman
Helper II
Helper II

Help with If Statement to modify text in query

I am brand new to M language and PowerQuery so I would greatly appreciate a little bit of an explanation along with an answer to this question so that I can learn!

 

I have a column of text values that are either "N/A" or a text string that starts with a space followed by various strings ex. " 5' Phos".

I need to alter this column to remove that first space from the string while leaving the "N/A" values the same.  I attempted to alter the function that auto-populated for me when I used the extract text after delimiter function (which worked on my strings but removed the "N/A" values). The function started as 

= Table.TransformColumns(PEN_OPS_CORE, {{"FivePrimeMod", each Text.AfterDelimiter(_, " "), type text}})

I tried to add an If statement but like I said I am brand new to this language and it did not work. 

= Table.TransformColumns(PEN_OPS_CORE_Fail_History, {{"FivePrimeMod", each if [FivePrimeMod]="N/A" then [FivePrimeMod] else Text.AfterDelimiter(_, " "), type text}})

 

any info and help would be greatly appreciated! including why my attempt did not work!

 

1 ACCEPTED SOLUTION
amustafa
Solution Sage
Solution Sage

Hi @aallman 

You can simply right mouse click on the column, select Transform -> Trim to remove the leading and trailing spaces before you do other transformations. This will not remove your N/A values.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
amustafa
Solution Sage
Solution Sage

Hi @aallman 

You can simply right mouse click on the column, select Transform -> Trim to remove the leading and trailing spaces before you do other transformations. This will not remove your N/A values.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Kudoed Authors