Search code examples
excelpowerbipowerquerypowerbi-desktopm

How to create a custom column in power query? If it is not contain numeric


I am trying to add a custom column in power query. if the column (A) has 6 digit number, I would like to contain the values from the B column, otherwise should contain values from the C column.

in another word:

New Custom Column = IF( A contains 6 digit, B, C)

How to get around this ? many thanks in advance.

enter image description here


Solution

  • Assuming columns are named a b c then add column ... custom column ...

    = try if Number.From([a])>99999 and Number.From([a])<1000000 then [b] else [c] otherwise [c]
    

    enter image description here