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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
mjohnsonsmi
Frequent Visitor

Two date calculations I can't find info on

Hello all,

 

I have data that can come in with a 30-45 day delay. I'm trying to set up a report that'll do the below, with that delay in mind. I can't find any examples that apply to my specific scenerio so here's what I'm trying to do.

 

Scenerio:

 

I run this report on April 1, the last date in the data is 2/23/2020. I want to get the sum of table SALES, column UNITS from 2/1/2020 - 2/23-2020. Taking the date of the last available record and the first date of that same month.

 

Then replicate the above but for the previous month so it's apples to apples. Showing me sales from 1/1/2020 - 1/23/2020.

 

Thoughts?

1 ACCEPTED SOLUTION

@mjohnsonsmi 

Please find solution at

https://www.dropbox.com/s/8wqtz6cfintxpa2/DateBasedonLastDate.pbix?dl=0

Screenshot 2020-03-01 15.21.16.png

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

7 REPLIES 7
mjohnsonsmi
Frequent Visitor

Thanks everyone for chiming in! Sample table is below, pretty vanilla setup.

 

Using the below example, this would get the sum of 1/14/2020 through 1/20/2020 but ignore the 1/27/2020 record. Only because the highest date in Feburary is 2/23/2020. Assume this report is getting run in April via automatic email subscription so no human interaction with selection fields is a requirement.

 

CSV download of the below https://drive.google.com/open?id=1vCUgb3879_JvXP69kCfoxG03UDMn_AhT 

 

DateUnitsModelFNameLNameCompany
1/14/20201Widget 1ClarkKentJustice League
1/20/20201Widget 3LexLuthorLegion of Doom
1/27/20201Widget 1PeterParkerSHIELD
2/2/20201Widget 2BruceWayneWayne Enterprises
2/11/20201Widget 1BruceBannerAvengers
2/17/20201Widget 1TonyStarkAvengers
2/23/20201Widget 3BlackWidowAvengers
      

@mjohnsonsmi 

Please find solution at

https://www.dropbox.com/s/8wqtz6cfintxpa2/DateBasedonLastDate.pbix?dl=0

Screenshot 2020-03-01 15.21.16.png

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you!

v-yingjl
Community Support
Community Support

Hi @mjohnsonsmi ,

Sample data and expected output would help tremendously.
Please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

 

Best Regards,

Yingjie Li

 

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

Tad17
Solution Sage
Solution Sage

Hey @mjohnsonsmi 

 

Have you thought about using a timeline slicer and the PARALLELPERIOD or more likely the DATEADD functions? Check out the thread in the link below as I believe it answers your problem: https://community.powerbi.com/t5/Desktop/Compare-data-with-previous-period-last-month/td-p/90426

 

If this helps please kudo.

If this solves your problem please accept it as a solution.

Greg_Deckler
Community Champion
Community Champion

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
kentyler
Solution Sage
Solution Sage

" I want to get the sum of table SALES, column UNITS from 2/1/2020 - 2/23-2020. "

You should be able to write a measure that gets the MIN() date in the table.

And from that date you can get the MONTH()

that should let you filter for the date range you want.

Once you know the current month you can use datediff to get the previous month (in case you're in Jan and it won't work to subtract 1). and then filter for the records in the previous month.

If you want help with the measure, post some sample data or, better yet, a sample power bi file and I'll write an example for you.





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors