question

naveen473 avatar image
0 Votes"
naveen473 asked MiguelCaballeroSierra-6578 commented

Power Query: Extract character based on conditon

Hi,
I am using power query and want to perform a simple algorithm.
In column A I have three characters. If the second character is a number I want to extract the first character. If the second character is a letter, want to extract the first two characters.
Not able to do this with “Add Column” => “Conditional Column” so some help would be appreciated.

power-query-not-supported
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MiguelCaballeroSierra-6578 avatar image
0 Votes"
MiguelCaballeroSierra-6578 answered MiguelCaballeroSierra-6578 edited

Hi @naveen473 ,

In a new Custom Column, try this:

     if
         Text.PositionOfAny ( 
             Text.At ( [Columna1], 1),
             {"1" .."9"}
         ) <> -1
     then
         Text.At ( [Columna1], 0 ) 
     else
         Text.Start ( [Columna1], 2 )

Where [Columna1] is subtitute with the name of your column

Best
— Miguel Caballero

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

naveen473 avatar image
0 Votes"
naveen473 answered MiguelCaballeroSierra-6578 commented

@MiguelCaballeroSierra-6578

This works smoothly. Thanks so much!!
Is there a Youtube video you can refer me to where I can learn the basics, please?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @naveen473

This conference by Chris Webb is a greate introduction to the M laguague: https://www.youtube.com/watch?v=S_uLkBP4sYk


Best
— Miguel Caballero

0 Votes 0 ·