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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
airportGR
Frequent Visitor

Month To Date - Default last Date as Yesterday - Help

Dear Power Bi Gurus,

 

I have set up my model to count Month To Date values for this Year and Last Year as shown at the picture. 

This is possible by manually selecting on a "Date Hierarchy" slicer. My results are correct this way. 

 

However, as this will be a daily automated report, I would like to always have Yesterday Date as my most recent date on my Month to Date calculations. 

 

This way my report will always reflect the "Start of Month - Yesterday" time period. 

 

Could you please help me on how to automatically have yesterday as my last date?

 

Thank you in advance. 

 

Capture.JPG

 

 

1 ACCEPTED SOLUTION

Dear @airportGR ,

 

 I enriched the sample data as follows.

picture_2.PNG

The following formula should do it for the last year.

picture_1.PNG

 

if you want to have it for two years ago please change the "YEAR(TODAY())-1" to "YEAR(TODAY())-2".

 

Did I solve your requests? Please mark my post as solution.

 

Appreciate your Kudos.

 

Best regards

Mikelytics

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

View solution in original post

4 REPLIES 4
airportGR
Frequent Visitor

Dear @Mikelytics 

Solution 1 works perfectly fine without any selection needed on the slicer

Solution 2 in order to work the slicer has to be selected (specific date ie 16/1/2021)

 

I am moving forward with Solution 1 (many thanks!)

 

Could you please advise on how to have the same MTD results for -1 and -2 years back (following Solution 1)

 

Thank you very much

Dear @airportGR ,

 

 I enriched the sample data as follows.

picture_2.PNG

The following formula should do it for the last year.

picture_1.PNG

 

if you want to have it for two years ago please change the "YEAR(TODAY())-1" to "YEAR(TODAY())-2".

 

Did I solve your requests? Please mark my post as solution.

 

Appreciate your Kudos.

 

Best regards

Mikelytics

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Dear @Mikelytics following your Solution 1 and adding the extra code for Last Year (-1) and (-2) solved my problem.

 

Thank you very much, I hope that this thread will help others too.

Mikelytics
Resident Rockstar
Resident Rockstar

Hi  @airportGR ,

 

did you try to solve this by putting the filter in the measure? I have two possible solutions based on the following sample data.

picture_1.PNG

(in Power BI I deleted the first row from the sample data)

Solution 1: if you want to use it in a KPI visual

picture_2.PNG

 

Solution 2: if you want to use it in a table or similar:

picture_3.PNG

Hope this helps.

 

Best regards

Mikelytics

 

--------------------------------------------------------------------------------------------------------------------------

 

Did I solve your requests? Please mark my post as solution.

 

Appreciate your Kudos.

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.