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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Count how many days between 2 measures is contained within filtered dates

I have created two measures minCheck and maxCheck, one to check the minimum date a campaign started and another to check the maximum date of the campaign.

I also have a date slicer from the calendar table, what I want to do is count how many days between minCheck and maxCheck consists within the date slicer.

So the date filtered is 27/06/2022 - 25/06/2023, so I need to return only the count of days that are within the selected date range which would be 96 days because 22/03/203 - 25/06/2023

 

joluwa_2-1707218588910.png

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

I modified the dax based on @PijushRoy 's and you can follow the steps below to fix the problem:
1.Add a mesure, DO NOT create relationships for dates in the slicer.

DateDiff = 
VAR selectmin =
    MIN ( 'Date Table'[Date] )
VAR selectmax =
    MAX ( 'Date Table'[Date] )
VAR _1 =
    IF ( selectmin <= [mincheck], [mincheck], selectmin )
VAR _2 =
    IF ( selectmax >= [maxcheck], [maxcheck], selectmax )
RETURN
    DATEDIFF ( _1, _2, DAY )

Final output:

vyifanwmsft_0-1707295597529.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

I modified the dax based on @PijushRoy 's and you can follow the steps below to fix the problem:
1.Add a mesure, DO NOT create relationships for dates in the slicer.

DateDiff = 
VAR selectmin =
    MIN ( 'Date Table'[Date] )
VAR selectmax =
    MAX ( 'Date Table'[Date] )
VAR _1 =
    IF ( selectmin <= [mincheck], [mincheck], selectmin )
VAR _2 =
    IF ( selectmax >= [maxcheck], [maxcheck], selectmax )
RETURN
    DATEDIFF ( _1, _2, DAY )

Final output:

vyifanwmsft_0-1707295597529.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

datediff using those dates will give 98 days, it needs to return 96 days because the user has filtered up to the 25th, so the 26th and 27th wont be included. So it needs to actually check whether the individual dates between those 2 measures exist within the selected date range

PijushRoy
Super User
Super User

Hi @Anonymous 

Please create a measure

 

DateDiff = DATEDIFF([MinDate],[MaxDate],DAY)

 

 

PijushRoy_0-1707219328869.png

 


Let me know if that works for you


If your requirement is solved, please make THIS ANSWER a SOLUTION ✔️ and help other users find the solution quickly. Please hit the LIKE 👍 button if this comment helps you.

Thanks
Pijush
Linkedin




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors