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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
dats
Resolver I
Resolver I

Conditionally Replace Values

Hi all,

 

I have two columns consisting of article numbers and a column that indicates if the article is sold online or not. Articles sold online do not have an article number. So I want to replace the value in Article Number based on if it was a sale online or not.

 

Ths is what I am using currently which doesn't seam to work as the article number for online sales is still empty/null

 

Table.ReplaceValue(#"Uppercased Text",each [ArticleNumber],each if Text.Contains([Source.Name],"Online")=true then [LeadingArticleNumber] else [ArticleNumber],Replacer.ReplaceText,{"ArticleNumber"})

 

If I add a custom column it works exactly as I would expect it. 

= Table.AddColumn(#"Filtered Rows2", "Custom", each if Text.Contains([Source.Name],"Online")=true then [LeadingArticleNumber] else [ArticleNumber])

 

the custom coulmn now has the same value for ArtcicleNumber as the LeadingArticleNumber when it is an online sale. 

 

No I am wondering wh does the conditional replacement doesn't seam towork?

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this line if that doesn't work.  Make sure the LeadingArticleNumber column is Text (or use Replacer.ReplaceValue).

 

= Table.ReplaceValue(#"Uppercased Text","Online", each [LeadingArticleNumber], Replacer.ReplaceText,{"ArticleNumber"})

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


BA_Pete
Super User
Super User

Hi @dats ,

 

Difficult to say without being able to see the data that you are applying this to, but the first thing I would try is to change

'Replacer.ReplaceText,{"ArticleNumber"})' at the end of your replace step to

'Replacer.ReplaceValue,{"ArticleNumber"})'.

 

Also, FYI, you don't need "=true" after the Text.Contains() function, it evaluates to boolean.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




hi @BA_Pete 

 

Thanks for the hint regarding "true" ou are right that was probably there from some test I made. 

I should have added that the ArticleNumber columne is a text columne. Was this what your tip is based on? But I will try regardless.

-dats

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.