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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Table Replace Value multiple condition

= Table.ReplaceValue(#"Expanded Code",each ([Geographical]="" or Text.Contains([Geographical],"INV")=true),"TBA",Replacer.ReplaceValue,{"Geographical"})

 

want to replace value to "TBA" if coulumn "Geographical" has null value or "INV".

Fomular has no error but result is not correct.

help~~ please.

1 ACCEPTED SOLUTION
gpoggi
Responsive Resident
Responsive Resident

Hi @Anonymous ,

 

Let me know if I get you well but this option helps you with what you need?

 

https://drive.google.com/open?id=1LlxMa2ScsJpsf0ZcCJ31vo5a0kyvbIZT

 

Also there are other options like custom column and create a new column based on other column values  but if you need to use the replace function in the same column that is how I would do it.

 

Any question, just let me know.

 

Regards,

 

Gian Carlo Poggi

View solution in original post

6 REPLIES 6
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

By my tests, the suggestion of Zubair_Muhammad should be right.

Here is the output.

Capture.PNG

If you have solved the problem, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

If you still need help, I think you could use the easiest way that you could replace the null to "TBA" then replace the "INV" to "TBV".

With that way, you don't need to code the power query, you could only use the option "Replace value" by right clicking the column.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
gpoggi
Responsive Resident
Responsive Resident

Hi @Anonymous ,

 

Let me know if I get you well but this option helps you with what you need?

 

https://drive.google.com/open?id=1LlxMa2ScsJpsf0ZcCJ31vo5a0kyvbIZT

 

Also there are other options like custom column and create a new column based on other column values  but if you need to use the replace function in the same column that is how I would do it.

 

Any question, just let me know.

 

Regards,

 

Gian Carlo Poggi

This worked for me. Thank you!

Hi,

How do I change this to be used in a function with column name as a variable ?

Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

With Table.ReplaceValue we can only replace one value at a time but you can specify multiple columns to make replacement in

 

https://docs.microsoft.com/en-us/powerquery-m/table-replacevalue

 

Alternatively, we can use a simple if statement

 

 =Table.AddColumn(#"Expanded Code", "Custom", each if [Geographical]="" or Text.Contains([Geographical],"INV") then "TBA" else [Geographical])

Regards
Zubair

Please try my custom visuals
Greg_Deckler
Super User
Super User

Calling in the master of M, the principal of Power Query, the...well...you get the idea. Help @ImkeF !!


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors