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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
aallman
Helper I
Helper I

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

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

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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