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
bwhitlock
Helper II
Helper II

Calculate purchases in a month 9 months forward from today

Im having an issue with my measure when it crosses years. Im trying to calculate my total purchase in a month 9 month from this month. I can calculate 2 or 3 months forward but when it transitions across years mess it up... How do I figure out what the date range should be in the month 9 months from this month?

Thanks all in advance

5 REPLIES 5
amitchandak
Super User
Super User

Like this

 

Measure =
var _max = today()
var _min = date(year(_max),month(_max)+9,day(_max))
return
calculate([measure],filter(All(DATE), Date[Date] >=_min && Date[Date] <=_max))

or
Measure =
var _max = eomonth(today(),-1)+1
var _min = eomonth(date(year(_max),month(_max)+9,1) ,0)
return
calculate([measure],filter(All(DATE), Date[Date] >=_min && Date[Date] <=_max))

 

or

Measure =
var _max = maxx(allselected('Date'),'Date'[Date])
var _min = date(year(_max),month(_max)+9,day(_max))
return
calculate([measure],filter(All(DATE), Date[Date] >=_min && Date[Date] <=_max))

Ashish_Mathur
Super User
Super User

Hi,

Try this measure

=Calculate([your_measure],datesbetween(Calendar[Date],Edate(Eomonth(Today(),-1)+1),9),Edate(Eomonth(Today(),0),9)))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Brilliant thank you so much. Had to make a slight adjustment as I think you have an extra parenth

 

Calculate([Tot Open PO Each Qty],datesbetween('Calendar Table'[Date],Edate(Eomonth(Today(),-1)+1,9),Edate(Eomonth(Today(),0),9)))

You are welcome.  If my reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mahoneypat
Employee
Employee

Have you tried DATEADD()?  This assumes you have a date calendar named Calendar and it is Marked as Date Table.

 

Measure = Calculate([YourMeasure], DATEADD(Calendar[Date], 9, month))

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.