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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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

@lbrown,

you can use the Date.AddDays() function: 

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

 

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

@lbrown,

you can use the Date.AddDays() function: 

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

 

Anonymous
Not applicable

Thanks it worked.

@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?

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.

Is there a way we can put a text tag saying "Yes/No" instead of the actual date @v-jiascu-msft @lbrown 

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.  

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.

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

This worked perfectly. Thank you @Anonymous

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.