daxrowcount

Row count base on Date criteria


Currently, I am facing an issue in a date difference calculation. I need your suggestions on how I can solve this issue. I need to count rows if the value exists between my date slicer range. In the screenshot provided:

  1. "Date of Admission-SNF" is the column I want to count.
  2. "MaxSelectedDate" represents the maximum date in my date slicer.
  3. "MinSelectedDate" represents the minimum date in my date slicer.
  4. In the "SNF Admitted" column, I want to display the result value if "Date of Admission-SNF" falls between "MaxSelectedDate" and "MinSelectedDate."

I am using Dax Formula as below:

SNF Admitted = COALESCE( CALCULATE( COUNTROWS('Patient Tracking'), FILTER( 'Patient Tracking', 'Patient Tracking'[Date of Admission- SNF (If Applicable)] >= [MinSelectedDate] && 'Patient Tracking'[Date of Admission- SNF (If Applicable)] <= [MaxSelectedDate] ) ), 0 )

enter image description here


Solution

  • i got solution for my issue. basically there were not need to use slicer range manually in DAX. I have use below code and got solution.

    COUNTROWS( FILTER( 'Patient Tracking', 'Patient Tracking'[Date of Admission- SNF (If Applicable)] >= MIN('Table'[Date]) && 'Patient Tracking'[Date of Admission- SNF (If Applicable)] <= MAX('Table'[Date]) ) )

    in above code "'Patient Tracking'[Date of Admission- SNF (If Applicable)]" data date column to whom i was calculating and  "'Table'[Date]" is my Period or Date table