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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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
Super User
Super User

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


@ 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!:
The Definitive Guide to Power Query (M)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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