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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jcampbell474
Helper IV
Helper IV

DAX Between two calculated dates

Good day, everyone.  Hoping someone can help me w/some DAX.

 

I need to count values if their date is -/+ 3-days from the activity date. 

 

Here's what I'm using, but it is not as accurate as it needs to be:

QuoteTest =
VAR selectedMin =
    FIRSTDATE ( ALLSELECTED ( CRMDetails[ActivityDate] ) )
VAR selectedMax =
    LASTDATE ( ALLSELECTED ( CRMDetails[ActivityDate3] ) )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( CRMDetails[AgentID] ),
        FILTER (
            ALL ( QMFact ),
            [DateQuoted] >= selectedMin
                && [DateQuoted] <= selectedMax
        )
    )


Without creating a calculated column, is there a way to do this in DAX?
 

1 REPLY 1
vivran22
Community Champion
Community Champion

Hello @jcampbell474 

 

You may try this:

 

 

Count within 3 Days = 
VAR _Duration = 3
VAR _StartDate = _SelectDate - _Duration
VAR _EndDate = _SelectDate + _Duration
VAR _Filter = 
    FILTER(
        ALLSELECTED(dtTable[Order Date]),
        dtTable[Order Date] >= _StartDate
        && dtTable[Order Date] <= _EndDate
    )
VAR _Count = 
    CALCULATE(
        [Distinct Orders],
        _Filter
    )   
RETURN
_Count

 

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂 (Hit the thumbs up button!)
If it doesn't, then please share a sample data along with the expected results (preferably an excel file and not an image)


https://www.vivran.in/

Connect on LinkedIn

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.