Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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 ...
  • Ashish_Mathur's avatar
    4 years ago

    Hi,

    You may download my PBI file from here.

    Hope this helps.

     

  • TomMartens's avatar
    4 years ago

    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:

    Hopefully, this provides what you are looking for.

     

    Regards,

    Tom