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
dhlavek
Frequent Visitor

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.

 

Capture.PNG

 

I appreciate any help.


Thanks.

1 ACCEPTED SOLUTION
LivioLanzo
Solution Sage
Solution Sage

 

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

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

Not sure if I am looking at your actual source data or what your slicer is based on, start or end date. Take a look this measure to see if it gets you closer to what you are looking for. It is designed to calculate things based upon slicer selections. 

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Most-Amazing-Mind-Blowing-Dynamic-Slicer...


@ 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...
LivioLanzo
Solution Sage
Solution Sage

 

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

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Perfect - thank you so much!

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.