Forum Discussion

Allisond's avatar
Allisond
Advocate II
5 years ago

Distinct Count Total: Filtered Column to Match a Measure Returning Blank

Good Morning,
 
I have 2 measures
      Measure1 is to get a max weight within a 30 day retro window and then pull out those with "significant" wt loss (> than 5%)
      Measure2 is to just get a distinct count of those patients that fell into the bucket of "significant wt loss. 
Measure2 is turning out to be much more difficult for me to figure out. 
 
Measure1:  
VAR Pt = SELECTEDVALUE(MSTR_Patient[PatientID])
VAR MaxDate = MAX(Dates[DayDate]) - 35
VAR MinDate = MAX(Dates[DayDate]) - 25
VAR PrevWt = CALCULATE(MAX(MeasurementValue[Lbs.]), DATESBETWEEN(Dates[DayDate], MaxDate, MinDate))
VAR SamePTChange = CALCULATE(PrevMeasurementValue[PatientID] = Pt)
VAR CurrentWeight = SUMX(MeasurementValues,MeasurmentValues[Lbs.])
VAR FirstVisDate = MIN(Dates[DayDate])
VAR LastAdmRtnDate = CALCULATE(MAX(MeasurementValuesRTNDate]),Dates[DayDate] <= FirstVisDate)
VAR Day30MAX = SWITCH(TRUE(), CurrentWeight = BLANK(),BLANK(),   LastAdmRtnDate >MAX(Dates[DayDate]) - 30, BLANK(), SamePTChange)
VAR WtLosslbs = Day30MAX - CurrentWeight
VAR WtLossPercent = DIVIDE(WtLosslbs,Day30MAX, BLANK())

RETURN
SWITCH(TRUE(),
WtLossPercent >= 0.05, SELECTEDVALUE(MeasurementValues[PatientID], BLANK() ))
 
Measure2:   CALCULATE   (DISTINCTCOUNT(MeasurementValue[PatientID]),
         FILTER   (MeasurementValues[PatientID] = Measure1,    BLANK()   ))
 
Measures 1 and 2 Pivot Table Result:
 
Pt ID
Date                                                        Measure1                                     Measure2                            
1234 
           01/01/01                                       1234                                             No result/Blank
2345             
           01/02/01                                        2345                                             No result/Blank
 
From what I understand in Dax, Measure 2 should result since Measure1 Result does = the PtID
 
I thought Measure1 would be the most difficult, but getting Measure2 is turning out to be much harder.  I just need a distinct count of those that qualified in Measure1.    If I adjust Measure2 without the filters and just a DISTINCTCOUNT (MeasurmentValue ([PatientID])     I get a result, but it is of all the patients weighed.  Not just those  with the ID result from Measure1.   
 
Any Assistance would be greatly appreciated.   Thank you!

1 Reply

  • v-alq-msft's avatar
    v-alq-msft
    Community Support

    Hi, Allisond 

     

    You may try the following measure to see if it helps.

    Measure2 =
    CALCULATE (
        DISTINCTCOUNT ( MeasurementValue[PatientID] ),
        FILTER ( ALL ( MeasurementValues ), MeasurementValues[PatientID] = Measure1 )
    )
    

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.