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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Vemul
Helper I
Helper I

Replace Values Based on Condition n Power Query

Hi Team,

please help, 

 

what I am looking is based on belwo table,

if Client is 99638 and Type is "Sample" then Client value to be changed to 99999.

if Client is 99567 and Type is "Sample" then Client value no chnage.

Vemul_0-1714998705409.png

could oyu please provide me query to solve this

Thanks

VJ

 

2 ACCEPTED SOLUTIONS
slorin
Super User
Super User

Hi, @Vemul 

 

= Table.ReplaceValue(Your_Source, each [Type], 99999, (x,y,z)=> if x=99638 and y="Sample" then z else x, {"Client"})

Stéphane

View solution in original post

dufoq3
Super User
Super User

Hi @Vemul

 

Before

dufoq3_0-1715000173218.png

 

After

dufoq3_1-1715000183499.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WsrQ0M7ZQ0lHyL8pMz8xLzFGK1QEJmpqZAwWDE3MLclKhQhB1KEIQVQitsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Client = _t, Type = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"Client", Int64.Type}}),
    ReplacedClient = Table.ReplaceValue(ChangedType,
        each [Client] = 99638 and [Type] = "Sample",
        each 99999,
        (x,y,z)=> if y then z else x,
        {"Client"} )
in
    ReplacedClient

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

6 REPLIES 6
Vemul
Helper I
Helper I

Thank you, Solution worked as expected.
Vemul
Helper I
Helper I

Thank you, Solution worked as expected.
Vemul
Helper I
Helper I

Thank you, Solution worked as expected.
Vemul
Helper I
Helper I

Thanks you, Solution worked as expected.
dufoq3
Super User
Super User

Hi @Vemul

 

Before

dufoq3_0-1715000173218.png

 

After

dufoq3_1-1715000183499.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WsrQ0M7ZQ0lHyL8pMz8xLzFGK1QEJmpqZAwWDE3MLclKhQhB1KEIQVQitsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Client = _t, Type = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"Client", Int64.Type}}),
    ReplacedClient = Table.ReplaceValue(ChangedType,
        each [Client] = 99638 and [Type] = "Sample",
        each 99999,
        (x,y,z)=> if y then z else x,
        {"Client"} )
in
    ReplacedClient

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

slorin
Super User
Super User

Hi, @Vemul 

 

= Table.ReplaceValue(Your_Source, each [Type], 99999, (x,y,z)=> if x=99638 and y="Sample" then z else x, {"Client"})

Stéphane

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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