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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Antmkjr
Post Patron
Post Patron

Replace a column value with dynamic value

Name
Anu
Tomy
Mikhayel
Jan-25
George
Thomas
Jerry

 

I have a table with sample data like this, i want to replace the entire column with the value Jan -25, the value of month is dynamic. And it is not necessarily current month. How to perform this in power query

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @Antmkjr, check this:

 

Output

dufoq3_0-1737560712488.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcswrVYrViVYKyc+tBDN8M7MzEitTc8Acr8Q8XQMjMNM9Nb8oPRWiNiM/N7EYoiC1qAioLxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t]),
    Date = List.Select(Source[Name], (x)=> (try Date.FromText("01-" & x) otherwise false) is date){0},
    Repalced = Table.TransformColumns(Source, {"Name", each Date, type text})
in
    Repalced

 


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

9 REPLIES 9
v-hashadapu
Community Support
Community Support

Hi @Antmkjr , Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @Antmkjr , Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @Antmkjr , Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details.
Thank you.

dufoq3
Super User
Super User

Hi @Antmkjr, check this:

 

Output

dufoq3_0-1737560712488.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcswrVYrViVYKyc+tBDN8M7MzEitTc8Acr8Q8XQMjMNM9Nb8oPRWiNiM/N7EYoiC1qAioLxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t]),
    Date = List.Select(Source[Name], (x)=> (try Date.FromText("01-" & x) otherwise false) is date){0},
    Repalced = Table.TransformColumns(Source, {"Name", each Date, type text})
in
    Repalced

 


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

v-hashadapu
Community Support
Community Support

Hi @Antmkjr , thank you for reaching out to the Microsoft Fabric Community Forum.

Try this:

  1. Power Query Editor -> Add Column -> Custom Column
  2. Give the new column name and in formula give the dynamic value to be replaced. Click ok.
  3. Manage Parameters -> New Parameter
  4. Give name(current month), type: text & current value(Jan-25).
  5. Go to Transform tab -> Replace values -> Replace values
  6. In Value to find, leave it blank of give *, In replace with give current month

    vhashadapu_4-1737541072966.pngvhashadapu_5-1737541107785.pngvhashadapu_6-1737541132883.pngvhashadapu_7-1737541164442.pngvhashadapu_8-1737541191143.pngvhashadapu_9-1737541217886.png

     

If this helps, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details.
Thank you.

Someway we are still hard coding Jan-25 in manage parameter. Suppose if have any other month we still cannot handle it dynamically

Hi @Antmkjr , thank you for reaching out to the Microsoft Fabric Community Forum.

 

Please try this:

let

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcswrVYrViVYKyc+tBDN8M7MzEitTc8Acr8Q8XQMjMNM9Nb8oPRWiNiM/N7EYoiC1qAioLxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t]),

   

    // Extract the month dynamically from the first valid date in the column

    FirstDate = List.Select(Source[Name], (x) => (try Date.FromText("01-" & x) otherwise false) is date){0},

    MonthYear = Text.Start(FirstDate, 6), // Extracts "Jan-25" from the date

   

    // Replace all values in the "Name" column with the dynamically extracted month

    Replaced = Table.TransformColumns(Source, {"Name", each MonthYear, type text})

in

    Replaced

 

If this helps, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details.
Thank you.

ZhangKun
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcswrVYrViVYKyc+tBDN8M7MzEitTc8Acr9SiIoiwe2p+UXoqRGlGfm5iMUQ+MU/XyFQpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t]),
    Repalce = Table.ReplaceValue(Source, null, List.Last(Source[Name]),(v,x,y)=>y,{"Name"})
in
    Repalce

Thank you for your input. But Jan -25 doesn't necessarily come in the last row always

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Kudoed Authors