Forum Discussion
How to use Filter selection in a DAX calculation
- 8 years ago
Thanks nickchobotar & ccakjcrx
I would like to appreciate both your effort to help me. I indeed learnt lot from you guys.
I was finally able to figure out the calculation,
CALCULATE(COUNT(PatientID), FILTER(ALL('DimDate'), [Date] <= MAX('DimDate'[Date])))
The above calculation resolved both my cases :)
Thanks again for your help and lots of suggestions.
Hey latheesh89!
I'm speculating here, but it sounds like the filter/slicer may be affecting the 'earliest' date. Given the adjustment to the filter context is yielding zero (i.e., no output), it sounds like the filter/slicer's has a beginning date that falls after the patient's discharge date. If that is true, then the filter context can produce 'nothing' in your example IF your expression isn't ignoring the filter context (i.e., the slicer).
That doesn't mean there is anything wrong with your data model; however, it means the expression calculating the 'patient stay' days ISN'T ignoring the filter context. In that case, the expression would need to be modified to ignore the filter context. Once that happens, you should get the correct 'patient stay' days (i.e., patient activity)--irrespective of filters/slicers.
I'm not sure you want to make your data available as it may contain PHI. If needed, you can msg me; I'll give you my phone number and I might be able to help out.
Thanks nickchobotar & ccakjcrx
I would like to appreciate both your effort to help me. I indeed learnt lot from you guys.
I was finally able to figure out the calculation,
CALCULATE(COUNT(PatientID), FILTER(ALL('DimDate'), [Date] <= MAX('DimDate'[Date])))
The above calculation resolved both my cases :)
Thanks again for your help and lots of suggestions.