Forum Discussion

SharonO's avatar
SharonO
New Member
1 year ago
Solved

Changing value from one column to another in PowerBi

Hi everyone Please can you help in changing a column value to another one Account Referrer Referrer needs to be 123456-1 Mr Jones Mr Jones 123456-2 Mr Smith Mr Jones 123456-3 Mr ...
  • vivien57's avatar
    vivien57
    1 year ago

    Ok, it's clear

    Steps in Power BI (Power Query):

    • Split the account into:
      • AccountPrefix = part before the -
      • AccountSuffix = part after the - (as a number)
    • Filter rows where AccountSuffix = 1 to get the original referrer.
    • Create a mapping table with AccountPrefix and Referrer.
    • Merge this mapping table back into the full dataset using AccountPrefix.
    • Replace Referrer:
      • If AccountSuffix = 1, keep the original.
      • Else, use the referrer from the merged table.
    • Clean up temporary columns and apply changes.

    Please feel free to give a kudo and validate my answer as a solution if it suits you.

    Have a nice day,

    Vivien