Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I am trying to create a week index for Power Query.
Any thoughts or if I am using the incorrect calculations?
M Code | StartOfCurrentWeek = Table.TransformColumnTypes(Table.AddColumn(#"Fiscal Year Status", "StartOfCurrentWeek", each Date.StartOfWeek(DateTime.FixedLocalNow(),+1)), {{"StartOfCurrentWeek", type date}}), StartOfWeek = Table.TransformColumnTypes(Table.AddColumn(StartOfCurrentWeek, "StartOfWeek", each Date.StartOfWeek([DateKey], 1)), {{"StartOfWeek", type date}}), #"Fiscal Week Index" = Table.TransformColumnTypes(Table.AddColumn(StartOfWeek, "Fiscal Week Index", each [StartOfWeek] - [StartOfCurrentWeek]), {{"Fiscal Week Index", Int64.Type}}), |
Screenshot |
|
Solved! Go to Solution.
7 or -7 is the difference in days, not weeks, so just divide by 7.
#"Fiscal Week Index" = Table.TransformColumnTypes(
Table.AddColumn(
StartOfWeek,
"Fiscal Week Index",
each ([StartOfWeek] - [StartOfCurrentWeek]) / 7
),
{{"Fiscal Week Index", Int64.Type}}
)
7 or -7 is the difference in days, not weeks, so just divide by 7.
#"Fiscal Week Index" = Table.TransformColumnTypes(
Table.AddColumn(
StartOfWeek,
"Fiscal Week Index",
each ([StartOfWeek] - [StartOfCurrentWeek]) / 7
),
{{"Fiscal Week Index", Int64.Type}}
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
14 | |
13 | |
12 | |
12 | |
12 |