Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
elaj
Helper IV
Helper IV

Replace multiple values in multiple columns in one step in power query

Hi,

 

i have a table like that:image.png

and i want to replace the string values to numbers like that:

 

"Last 4 weeks" = 1
"2 months ago" = 2
"3 months ago" = 3
"4 months ago" = 4
... etc

 

is there a way to do the replace with this multiple values in multiple custom selected columns in one step in power query?

i only found solutions for multiple values for one column... or one value for multiple columns.

 

Thanks for your answers

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi , @elaj 

I'm afraid  there is no way to do the replace with this multiple values in multiple custom selected columns in one step in power query.

As shown in this document, the  syntax structure  of function "Table.Replace.Value"  does not seem to support the branch structure  something like "each if .. then..". 

Even if you use conditional columns, you can only operate column one by one.

 

Best Regards,
Community Support Team _ Eason

View solution in original post

5 REPLIES 5
v-easonf-msft
Community Support
Community Support

Hi , @elaj 

I'm afraid  there is no way to do the replace with this multiple values in multiple custom selected columns in one step in power query.

As shown in this document, the  syntax structure  of function "Table.Replace.Value"  does not seem to support the branch structure  something like "each if .. then..". 

Even if you use conditional columns, you can only operate column one by one.

 

Best Regards,
Community Support Team _ Eason

Anonymous
Not applicable

Hello!

You can transform the variable (transform/ Replace values), remember that there you must take into account that the source variable is in text and you want to change it and that it is numbered (by clicking new parameter and there you select the type of variable).

Sin título.jpg

I usually like to leave the original variable. To do this, I add a new conditional column (add column/conditional column).

Sin título.jpg

I hope it works 🙂 for you.

harshnathani
Community Champion
Community Champion

Hi @elaj ,

 

You can do this in Power Query.

 

 

Go to the Transform Ribbon and Select Replace Value.

 

You can replace the values one by one.

 

1.jpg

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

Greg_Deckler
Super User
Super User

@elaj - Are you trying this in Power Query, DAX or do you care?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Oh i'm sorry.. i forgot to mention. I mean in power query

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.