Search code examples
powerquerym

How do I change the content of a column to pick from another column based on a criteria, leaving that column blank WHEN it does pick from it


I need to replace the value of a column(LastName) with values from another column('MiddleName') IF column "LastName" contains "." and column B contains non null values while deleting the content of column('MiddleName') only if the content has been moved to column ("LastName").

NIL

NIL

That Column 'MiddleName' becomes blank if column "LastName" contained "." and the column 'MiddleName' (which had content) has now been moved to column "LastName".

For instance; if the columns contained;

MiddleName   LastName
john            .
james        phillips
Mary            .

The procedure should then make it:
MiddleName   LastName
             john 
james        phillips
             Mary                                                                                     

Solution

  • This is easier to do with new custom columns rather than replacing the existing ones.

    Middle = if [LastName] = "." then null else [MiddleName]
    
    Last   = if [LastName] = "." then [MiddleName] else [LastName]