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
Mage
Frequent Visitor

Loop in Power Query to get date

Hi,

Basically I have a weekly plan through a whole month, the table may like this:

Mage_0-1725959128284.png

The plan will be handled from 1st weekday(Start Day) to 4rd weekday(End Day) each week, I want to transform them to concrete Start Dates and End Dates in the table by creating custom columns. The expected output may like:

Mage_1-1725959145526.png

How can I arrive it in Power Query instead of using DAX, perhaps it needs to be loopped but it confused me a lot.

 

Regards

 

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi @Mage 

Start Date

Date.AddDays(Date.StartOfWeek([Date],0),[Start Day])

End Date

Date.AddDays(Date.StartOfWeek([Date],0),[End Day]) 

Stéphane 

View solution in original post

3 REPLIES 3
Omid_Motamedise
Super User
Super User

You do not need loop in this case, and you can easily solve it bu using the next code

 

let
    Source = Table.FromColumns({List.Dates(#date(2024,7,1),31,#duration(1,0,0,0))},{"Date"}),
    #"Added Custom" = Table.AddColumn(Source, "Start Date", each Date.StartOfWeek([Date])),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "End Date", each Date.StartOfWeek([Date])+#duration(3,0,0,0))
in
    #"Added Custom1"

 

in another casaes, if you need loop, check this video
https://www.youtube.com/watch?v=G8PRbWuDcmQ&t=12s

 


If my answer helped solve your issue, please consider marking it as the accepted solution.
slorin
Super User
Super User

Hi @Mage 

Start Date

Date.AddDays(Date.StartOfWeek([Date],0),[Start Day])

End Date

Date.AddDays(Date.StartOfWeek([Date],0),[End Day]) 

Stéphane 

Mage
Frequent Visitor

Thank you for the help, it reminds me a lot, but the actual will be more complex, I will post a new thread.

 

Regards

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.

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