Forum Discussion
jcampbell474
Helper IV
6 years agoDAX 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
- vivran22
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 _CountCheers!
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