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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Calculate measure with multiple dates

I am struggling with a calculation of measure with 2 dates. 

 

My table below has 2 dates.  Trying to calculate sum of quantity by revision dates. My filter is on Calendar date which has an active relation with revision date. 

 

Pbi07_0-1635562856883.png

expected result

Sum for selected date of oct15 , should be only 35( excluding the  6th Nov Purch Date ) . Basically, depends on the calendar day selection, total should be only with Purch date of Selected date month. I tried using userelationship, but that didn't work. 

Any advice will help. 

 

 

My pbix is https://drive.google.com/file/d/1cMeCbzFtPWDP-ABJ0itxiwnlc_T2QIFr/view?usp=sharing

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

 


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

View solution in original post

TomMartens
Super User
Super User

Hey @Anonymous ,

 

next to the solution provided by @Ashish_Mathur , here is another approach that only makes use of the tables

  • Revision Table
  • Calendar

 

 

Tom = 
var MAXSelectedDate = MAX('Calendar'[Date] )
var SelectedYear = YEAR( MAXSelectedDate )
var SelectedMonth = MONTH( MAXSelectedDate )
var EoMofSelectedDate = EOMONTH( MAXSelectedDate , 0 )
var __AllPurchDatesInSelectedMonth = DATESBETWEEN( 'Calendar'[Date] , DATE( SelectedYear , SelectedMonth , 1) , EoMofSelectedDate )
return
CALCULATE(
    SUM( 'Revision Table'[Quantity] )
    , 'Revision Table'[Purch Date] IN  __AllPurchDatesInSelectedMonth
)

 

 

A little screenshot:
image.png

Hopefully, this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey @Anonymous ,

 

next to the solution provided by @Ashish_Mathur , here is another approach that only makes use of the tables

  • Revision Table
  • Calendar

 

 

Tom = 
var MAXSelectedDate = MAX('Calendar'[Date] )
var SelectedYear = YEAR( MAXSelectedDate )
var SelectedMonth = MONTH( MAXSelectedDate )
var EoMofSelectedDate = EOMONTH( MAXSelectedDate , 0 )
var __AllPurchDatesInSelectedMonth = DATESBETWEEN( 'Calendar'[Date] , DATE( SelectedYear , SelectedMonth , 1) , EoMofSelectedDate )
return
CALCULATE(
    SUM( 'Revision Table'[Quantity] )
    , 'Revision Table'[Purch Date] IN  __AllPurchDatesInSelectedMonth
)

 

 

A little screenshot:
image.png

Hopefully, this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

 


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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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