Forum Discussion
How to rename column name as current Date dynamically?
- 6 years ago
Try the below.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtFTSUTJVitUhgmOElWMB5BgaEMuzQOPEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Year = _t, #"Value " = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}, {"Value ", Int64.Type}}), #"Renamed Columns" = Table.RenameColumns(#"Changed Type", { { "Year", let currentDateTime = DateTimeZone.LocalNow(), currentYear = Number.ToText( Date.Year( currentDateTime ) ), currentMonth = Date.MonthName( currentDateTime ) in currentYear & "-" & currentMonth } } ) in #"Renamed Columns"Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
Hi dufoq3 ,
Currently my input table looks like this,
I am fetching current month + remaining months of the year+ next year all the months. This is the logic to fetch months every time. These months I am fetching it from calendar table and appending here.
In my original table, i have months till Dec_NFY.
Now Estimate q1 value has to be copied to Where ever my table has Jan, Feb, Mar
Estimate q2 value has be copied to all the columns starts with Apr May jun
Same logic goes to Q3 and Q4 as well.
Sample output.
I am trying to do with this code.
#"Replacevalue" = Table.ReplaceValue(#"Appended Query",
each Text.StartsWith(_,"Jan") , each [Estimate Q1] , Replacer.ReplaceText, {"Jan"})
This code is not working.
Could you pls help me with this issue?
Thanks in advance.