Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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}}
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
9 | |
7 | |
6 | |
6 |