Forum Discussion
DAX - Frequency Count.
- 7 years ago
Hi amaleranda ,
1. To create a calculated column as below.
Column = CALCULATE ( SUM ( 'Table'[Avil] ), FILTER ( ALL ( 'Table' ), 'Table'[Time] <= EARLIER ( 'Table'[Time] ) && 'Table'[Group] = EARLIER ( 'Table'[Group] ) ) )2.Then we can create the Frequency measure.
Frequency = CALCULATE(DISTINCTCOUNT('Table'[Column]),FILTER('Table','Table'[Avil] = 0))
how do we allow this result set to still be filtered by a dimension? for example a date table. I am trying to get to the count of hospitalizations per patient (within a given selected timeframe) - and then count distinct patients in buckets of "1 hospitalization", "2 hospitalizations", "3 or more" etc. So I am trying to first get a rolled up value of 'hospitalizations' in the selected date range using the above approach
Column =
var dMin = FIRSTDATE(ALLSELECTED('Service Date'[Service Date]))
var dMax = LASTDATE(ALLSELECTED('Service Date'[Service Date]))
return
CALCULATE (
DISTINCTCOUNT( 'Hospitalizations'[UniqueHospitalization] ),
FILTER (
ALL ( 'Hospitalizations' ),
'Hospitalizations'[Person Served Key] = EARLIER ( 'Hospitalizations'[Person Served Key]) && Hospitalizations[Hospitalization Begin Date]>= dmin && Hospitalizations[Hospitalization Begin Date] <=dMax
)
)