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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.