cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
lbrown Helper I
Helper I

Formula for adding yesterday's date in a new column in Power Query in Excel and Power BI

I need to add a new column that shows yesterday's date. The formula I have to calculate today's date is:

 

Date.From(DateTime.FixedLocalNow())

 

This new column shows me today's date, but I need the column to show yesterday's date. I tried the following combination and I am receiving Error in each cell.

 

Date.From(DateTime.FixedLocalNow()) -1

 

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Formula for adding yesterday's date in a new column in Power Query in Excel and Power BI

@lbrown,

you can use the Date.AddDays() function: 

Date.AddDays(Date.From(DateTime.FixedLocalNow()),-1)

 

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Re: Formula for adding yesterday's date in a new column in Power Query in Excel and Power BI

@lbrown,

you can use the Date.AddDays() function: 

Date.AddDays(Date.From(DateTime.FixedLocalNow()),-1)

 

View solution in original post

lbrown Helper I
Helper I

Re: Formula for adding yesterday's date in a new column in Power Query in Excel and Power BI

This worked perfectly. Thank you @Anonymous

lbrown Helper I
Helper I

Re: Formula for adding yesterday's date in a new column in Power Query in Excel and Power BI

@Anonymous

 

Update: I added the new column in Power Query Editor and I went back to my dashboard tab to Refresh the Pivot Charts but they are all blank now and I have to rebuild them. Do you know how I can fix this?

Microsoft v-jiascu-msft
Microsoft

Re: Formula for adding yesterday's date in a new column in Power Query in Excel and Power BI

Hi @lbrown,

 

Can you share the file? How did you create the chart? Maybe the old charts use the date "Today" while you change it into "Yesterday".

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
lbrown Helper I
Helper I

Re: Formula for adding yesterday's date in a new column in Power Query in Excel and Power BI

Hi @v-jiascu-msft

 

Unfortunately I'm not able to share the spreadsheet because the data is confidential to my company. I loaded the data table to the Data Model and created the pivot tables based on the workbook's Data Model. The pivot charts were created from the pivot tables. The pivot tables and charts don't currently use a reference to the new data column, but when I added the new column and pressed refresh all they are simply going blank when I refresh.  

Microsoft v-jiascu-msft
Microsoft

Re: Formula for adding yesterday's date in a new column in Power Query in Excel and Power BI

Hi @lbrown,

 

Can you build a dummy one? Sorry, I can't give more suggestions without the data model.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
lbrown Helper I
Helper I

Re: Formula for adding yesterday's date in a new column in Power Query in Excel and Power BI

Hi Dale,

 

I rebuilt the Excel Sheet in Power BI and I have no problems updating the charts after I add new columns. This error may be an Excel issue, but thank you for your assistance.

 

Best, 

Lauren

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors
Top Kudoed Authors