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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join 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
Community Champion
Community Champion

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
Community Champion
Community Champion

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
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.