Forum Discussion
Census by admit/discharge By Date Range
4 Replies
- mahoneypat
Microsoft Employee
Do you have a relationship to your Dates table? If so, you'll need an ALL() or REMOVEFILTERS() to remove the filter coming from that (added below). Also, I think you could simplify your DAX as follows:
Census =
VAR __mindate =
MIN ( Dates[DayDate] )
VAR __maxdate =
MAX ( Dates[DayDate] )
RETURN
CALCULATE (
[TotalEpisodes],
ALL ( Census ),
Census[StartDate] <= __maxdate,
Census[BillingEndDay] >= __mindate
)If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
- Allisond
Advocate II
I need to be able to filter by location once I get the total days by date range. Is there anyway not to include "ALL" and maintain filterability? Sorry so many questions.
- mahoneypat
Microsoft Employee
Yes. Not seeing your model, I suggested ALL(Census), but you can be more targeted on which filters you remove. For example, you could replace ALL(Census) with either ALL(Date) or ALL(Census[StartDate], Census[EndDate). I can't see original column names in reply window, so not sure if those are right, but you get the idea. These would keep in place the filters on the other columns. You could also try ALLSELECTED(Census) to keep filters coming from outside the visual.
Regards,
Pat
- v-xicai
Community Support
Hi Allisond ,
You may change your formula like DAX below.
Census = VAR _date = SELECTEDVALUE ( Dates[DayDate] ) RETURN CALCULATE ( [TotalEpisodes], FILTER ( ALLSELECTED ( Census ), Census[StartDate] <= _date && Census[BillingEndDay] >= _date ) )Best Regards,
Amy
Community Support Team _ Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.