Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I'm new to this:
I'm trying to replace column headers with the current week in one column and iterate from there. For example, I have columns that say "week 1", "week 2", "week 3".....etc. I would like to replace "week 1" with the date of the current week (start or end doesn't matter), "week 2" as a week from now, "week 3" as two weeks from now, and so on. Is that possible?
Solved! Go to Solution.
Hello @jcbutts
I recognized that I got you wrong. So week 1 is always the current week.
I fixed this now. Check out this one if it works
let
Source = #table
(
{"week 1","week 2","week 3","other data","abc","week 52"},
{
{"","","","","",""}
}
),
ColumnNames = Table.ColumnNames
(
Source
),
TransformWeekInDate = List.Transform
(
ColumnNames,
(row)=> try
if Text.Contains(row,"week") or Text.Contains(row,"Week") then
Text.From(Date.AddDays(Date.AddDays( Date.From(DateTime.FixedLocalNow()), Date.DayOfWeek(DateTime.FixedLocalNow())*-1), (Number.From(Text.Replace(row, "week ", ""))-1)*7))
else
row
otherwise
row
),
RenameColumnHeader = Table.RenameColumns
(
Source,
List.Zip({ColumnNames,TransformWeekInDate})
)
in
RenameColumnHeader
Jimmy
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.