Forum Discussion

elainepowell's avatar
elainepowell
Frequent Visitor
3 years ago
Solved

Power BI Replace if multiple conditions

There's duplicate AD data that I need usable.

 

If there's a specific city name and it's within TX district, I want to add TX to it.

This requires checking for the city name from one column and checking for TX in the district column.

 

Table.ReplaceValue(
#"previous",
each [AD.physicalDeliveryOfficeName],
each if [AD.physicalDeliveryOfficeName] = "City" and {"AD-person.district"} = "TX"
then "City TX"
else [AD.physicalDeliveryOfficeName],
Replacer.ReplaceText, {"AD.physicalDeliveryOfficeName"}
)

 

It's not working.

Anyone know how I can fix this?

  • It looks like it was a glitch with the name of the second column.

    On a whim, I renamed the column and now the replace works.

3 Replies

    • elainepowell's avatar
      elainepowell
      Frequent Visitor

      The dataset is awkward, but maybe this will work?

      AD.physicalDeliveryOfficeNameAD-person.district
      Lake StevensWA
      College StationTX
      LoganUT
      MurrayUT
      KirklandWA
      CityTX
      CityOR
      BellinghamWA
      LancasterCA
      StocktonCA
      Santa RosaCA
      Van NuysCA
      PompanoFL
      KendallFL
      EverettWA
      AlbuquerqueNM
      El CentroNM
      CityTX
      CityOR
      VisaliaCA
      ClovisCA
      NovatoCA
      MercedCA
      San FranciscoCA
      LivermoreCA
      Miami LakesFL
      N MiamiFL
      Staten IslandNY
      BrooklynNY
      YonkersNY
      Port ChesterNY
      Boca RatonFL
      Auburn HillsMI
  • elainepowell's avatar
    elainepowell
    Frequent Visitor

    It looks like it was a glitch with the name of the second column.

    On a whim, I renamed the column and now the replace works.