Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Sum by date with Start date and End date

I'm trying to get a sum  of Count (hoping to filter using the Timeline slicer).  If the slicer is filtering by year, I'd want any project to be included in the sum if the Start Date to End Date contained the filtered Year.   In the set below, if the slicer was filtered to 2015, I'd want it to return 675 (projects 1-3).

 

If the slicer was filtered down to an individual day, I'd want the sum to included all projects where the Start Date to End date includes that filtered date.  So if it was filtered to 4/1/2015 it would sum Project 2 and Project 3.

 

 

I appreciate any help.


Thanks.

  •  

     if you have a date slicer linked to a table named Dates then try

     

     

    =
    VAR MnDte =
        MIN ( Dates[Date] )
    VAR MxDte =
        MAX ( Dates[Date] )
    RETURN
        CALCULATE (
            SUM ( Projects[Count] ),
            NOT ( Projects[Start Date] > MxDte ),
            NOT ( Projects[End Date] < MnDte )
        )

3 Replies

  •  

     if you have a date slicer linked to a table named Dates then try

     

     

    =
    VAR MnDte =
        MIN ( Dates[Date] )
    VAR MxDte =
        MAX ( Dates[Date] )
    RETURN
        CALCULATE (
            SUM ( Projects[Count] ),
            NOT ( Projects[Start Date] > MxDte ),
            NOT ( Projects[End Date] < MnDte )
        )

    • Anonymous's avatar
      Anonymous
      Not applicable

      Perfect - thank you so much!