cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
askspepsi
Helper II
Helper II

Power Query Start date to today

Greeting All,

 

IdStart DateDate Master
101/05/202101/05/2021
101/05/202102/05/2021
101/05/202103/05/2021
101/05/202104/05/2021
101/05/202105/05/2021
101/05/202106/05/2021
101/05/202107/05/2021
101/05/202108/05/2021
101/05/202109/05/2021
101/05/202110/05/2021
101/05/202111/05/2021
101/05/202112/05/2021
101/05/202113/05/2021
101/05/202114/05/2021
101/05/202115/05/2021
101/05/202116/05/2021
101/05/202117/05/2021
101/05/202118/05/2021
101/05/202119/05/2021
101/05/202120/05/2021
101/05/202121/05/2021
101/05/202122/05/2021
101/05/202123/05/2021
101/05/202124/05/2021
101/05/202125/05/2021
101/05/202126/05/2021
101/05/202127/05/2021
211/05/202111/05/2021
211/05/202112/05/2021
211/05/202113/05/2021
211/05/202114/05/2021
211/05/202115/05/2021
211/05/202116/05/2021
211/05/202117/05/2021
211/05/202118/05/2021
211/05/202119/05/2021
211/05/202120/05/2021
211/05/202121/05/2021
211/05/202122/05/2021
211/05/202123/05/2021
211/05/202124/05/2021
211/05/202125/05/2021
211/05/202126/05/2021
211/05/202127/05/2021

 

I have used the below query for 100days but I want to add today() function instead of 100.

Date Master=List.Dates([Start Date], 100, #duration(1, 0, 0, 0))

 

Please help to change this Query.

 

Thank you,

askspepsi

1 ACCEPTED SOLUTION
Fowmy
Super User IV
Super User IV

@askspepsi 

Your formula is creating a list of dates from [Start Date] with 100 days. IF not 100 days, what exactly is required there?
Today is a Date, you a number. if you need today's date in PQ Date.From(DateTimeZone.LocalNow())

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
Fowmy
Super User IV
Super User IV

@askspepsi 

Your formula is creating a list of dates from [Start Date] with 100 days. IF not 100 days, what exactly is required there?
Today is a Date, you a number. if you need today's date in PQ Date.From(DateTimeZone.LocalNow())

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

@Fowmy 

You are correct, my formula is creating for 100days, but for time being and to make the formula work I kept as 100days, but in reality, it should take today's date for example:- one employee starts from May 1st, 2021 then the date master should have 1st May 2021 to 27th May 2021 and when it is tomorrow the date master should be 1st May 2021 to 28 May 2021.

 

As you said to use Date.From(DateTimeZone.LocalNow()),

My Formula is now working fine, Thank you.

List.Dates([Start Date], Duration.Days(Date.From(DateTimeZone.LocalNow()) -[Start Date])+1 , #duration(1, 0, 0, 0))

amitchandak
Super User IV
Super User IV

@askspepsi , Try like

Date Master=List.Dates([Start Date], Duration.Days(today() -[Start Date]) , #duration(1, 0, 0, 0))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

@amitchandak 

I have got the below error

Expression.Error: The name 'today' wasn't recognized. Make sure it's spelled correctly.

@amitchandak 

Thanks for the reply,

Will today() function work in Power Query.

 

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors