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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Replace all values that are not of a certain set in one column

Hi,

I am trying to replace all values that are not in the following list by -2.

I am not sure how to go about it.

When the value is NOT in the following list, I want it to be -2:

{2166,3033,5175,0883}

 

 

Here is what I see when I click on advanced  editor:

let
Source = OData.Feed("some link", null, [Implementation="2.0"]),
Issues_table = Source{[Name="Issues",Signature="table"]}[Data],
#"Filtered Rows" = Table.SelectRows(Issues_table, each true),
#"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"ISSUE_ID", Order.Ascending}}),
#"Replaced Value" = Table.ReplaceValue(#"Sorted Rows",null,-1,Replacer.ReplaceValue,{"ISSUE_ID"}),
#"Sorted Rows1" = Table.Sort(#"Replaced Value",{{"ISSUE_ID", Order.Ascending}})
in
#"Sorted Rows1"

 

 

Thanks!

1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

Hi @Anonymous ,

 

I noticed a number starting with a 0 please know that the value for the number 0883 is 883

Anyway, give this a go:

 

Table.ReplaceValue(Source,each [ISSUE_ID],each if List.Contains({2166,0883,3033,5175}, [ISSUE_ID]) then [ISSUE_ID] else -2,Replacer.ReplaceValue,{"ISSUE_ID"})

 

m_dekorte_0-1682698863468.png

Ps. If this helps solve your query please mark this post as Solution, thanks!

View solution in original post

1 REPLY 1
m_dekorte
Super User
Super User

Hi @Anonymous ,

 

I noticed a number starting with a 0 please know that the value for the number 0883 is 883

Anyway, give this a go:

 

Table.ReplaceValue(Source,each [ISSUE_ID],each if List.Contains({2166,0883,3033,5175}, [ISSUE_ID]) then [ISSUE_ID] else -2,Replacer.ReplaceValue,{"ISSUE_ID"})

 

m_dekorte_0-1682698863468.png

Ps. If this helps solve your query please mark this post as Solution, thanks!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors