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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
mb0307
Responsive Resident
Responsive Resident

Week offset in Power Query

Hi all,

 

I have this measure in DAX which works absolutely fine.   I want this to be in Power Query, please help:

Week Offset = 
Var StartOfWeek = 'Calendar'[Date] - WEEKDAY( 'Calendar'[Date], 2)+1
Var StartOfCurrentWeek = TODAY() - WEEKDAY(TODAY(), 2)+1
Return (StartOfWeek - StartOfCurrentWeek)/7

 

Thanks much 

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @mb0307 

 

Add a Custom column with this code in Power Query:

(Date.StartOfWeek([Date])-Date.StartOfWeek(DateTime.Date(DateTime.LocalNow())))/7

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

View solution in original post

7 REPLIES 7
Jon_vB
Advocate II
Advocate II

I needed the week offset where a week starts on Saturday.  Here's what I came up with - in case anyone else needs it (and - thanks to VahidDM for most of the work!)

 

Number.From(Date.StartOfWeek([Date],Day.Saturday) - Date.StartOfWeek(Today,Day.Saturday))/7
 
(the Number.From gets rid of the time formatting that romoguy15 points out)
peifc75
Frequent Visitor

I have looked for this week offset everywhere. I was having a hard time figuring how to set it up. Thank you. Your solution really helped.

Anonymous
Not applicable

Great solution. To set the right datatype in one line use this.

= Table.AddColumn(Previous_M_Query_Step, "Name_Column", each
(Number.From((Date.StartOfWeek([Datum])-Date.StartOfWeek([Huidige_Datum]))/7)),Int64.Type)
VahidDM
Super User
Super User

Hi @mb0307 

 

Add a Custom column with this code in Power Query:

(Date.StartOfWeek([Date])-Date.StartOfWeek(DateTime.Date(DateTime.LocalNow())))/7

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

Excellent solution, do you know how to change the number to be a whole number all within the same formula? Just to take out the the time zeros from the number

romoguy15_0-1652910021886.png

 

romoguy15_1-1652910034268.png

 

nevermind, i figured out. Was simple. Just add a data type in the custom column section.

mb0307
Responsive Resident
Responsive Resident

Worked perfectly.  Thanks

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors