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
Anonymous
Not applicable

Find Next Date/Day in Power Query

I have two tables for which I need to find a date. In other words, I am trying to solve two problems which I feel are closely related.

 

Table 1: Has today's date in a column. From this date I need to populate another column with the date of the next Friday. In other words, if today is 10/6/19, I want the new column to populate with 10/11/19.

 

Table 2: Has the day number of "1" in a column. From this number, I need to populate another column with next month's date using that day number. In other words, if today is 10/6/19, I want the new column to populate with 11/1/19.

 

Any help would be much appreciated. I know how to do this in Excel, but after reviewing a bunch of posts and a list of M date functions, I'm at a loss.

 

Thanks!

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi battery514,

If the date is 2019/10/7, did you want to get another column as 2019/10/18? And did you want to use day number "1"  as next month 's day? If so, you  could try to use below M code to see whether it work or not.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNS31DeyUNJRMlSK1YGKGBrom2GImANFjFBEDI2BQsaoQiZAIROl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [date = _t, day = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type date}, {"day", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Date.DayOfWeek([date])=6 or Date.DayOfWeek([date])= 0 then Date.EndOfWeek([date],Day.Saturday) else Date.AddDays(Date.EndOfWeek([date],Day.Saturday),7)),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each DateTime.Date(#datetime(Date.Year([date]),Date.Month([date])+1,[day],0,0,0)))
in
    #"Added Custom1"

399.PNG

Best Regards,
Zoe Zhi

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hello @Anonymous 

 

Table 1: Has today's date in a column. From this date I need to populate another column with the date of the next Friday. In other words, if today is 10/6/19, I want the new column to populate with 10/11/19.

 

Solution- try this

new_date = IF(Table[day_nm]="Monday",[today]+4,IF(Table[day_nm]="Tuseday",[today]+3,IF(Table[day_nm]="Wensday",[today]+2,IF(Table[day_nm]="Thursday",[today]+1,IF(Table[day_nm]="Friday",[today]+0)))))
 
 
dax
Community Support
Community Support

Hi battery514,

If the date is 2019/10/7, did you want to get another column as 2019/10/18? And did you want to use day number "1"  as next month 's day? If so, you  could try to use below M code to see whether it work or not.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNS31DeyUNJRMlSK1YGKGBrom2GImANFjFBEDI2BQsaoQiZAIROl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [date = _t, day = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type date}, {"day", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Date.DayOfWeek([date])=6 or Date.DayOfWeek([date])= 0 then Date.EndOfWeek([date],Day.Saturday) else Date.AddDays(Date.EndOfWeek([date],Day.Saturday),7)),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each DateTime.Date(#datetime(Date.Year([date]),Date.Month([date])+1,[day],0,0,0)))
in
    #"Added Custom1"

399.PNG

Best Regards,
Zoe Zhi

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

Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

Try this custom column\

 

=Date.AddDays(
Date.EndOfWeek([ColumnName]),-1)

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
Top Kudoed Authors