Forum Discussion

cheezy's avatar
cheezy
Icon for Helper I rankHelper I
6 years ago

Calculated Field formula doesn't work as intended

eGFR Months = DATEDIFF(app_appointments[eGFR_test_date],TODAY(),MONTH)

Age = FLOOR(IF([dob]< TODAY(), DATEDIFF([dob], TODAY(), DAY) / 365.25, 0), 1)

 

i have two calculated fields in different tables defined as above  - these work fine on their own

trying to get a formula below to work : ie anyone over 70 who have not had an eGFR recently needs a blood test.

 

Blood Test =
var _t1 = SELECTEDVALUE(app_patient_details[Age])
var _t2 = SELECTEDVALUE(app_appointments[eGFR months])
return
IF( (_t1 >69 && _t2 > 0), "Blood Test","Not Working")
 
But the formula always returns false  even if i change to
Blood Test =
var _t1 = SELECTEDVALUE(app_patient_details[Age])
var _t2 = SELECTEDVALUE(app_appointments[eGFR months])
return
IF( (_t1 =70), "Blood Test","Not Working")
 
 or
 
Blood Test =
var _t1 = SELECTEDVALUE(app_patient_details[Age])
var _t2 = SELECTEDVALUE(app_appointments[eGFR months])
return
IF( t2 > 0), "Blood Test","Not Working")
 
 

 

aany ideas? thanks

 
 

4 Replies

  • cheezy , you need row value then it should be the max not selected value.

    Please find one formula changed

     

    Blood Test =
    IF( (max(app_patient_details[Age]) >69 && max(app_appointments[eGFR months]) > 0), "Blood Test","Not Working")

    • cheezy's avatar
      cheezy
      Icon for Helper I rankHelper I

      This didn't work unfortunately- all rows return blood test now irrespective of age or egfr

  • FarhanAhmed's avatar
    FarhanAhmed
    Icon for Community Champion rankCommunity Champion

    Hi cheezy 

    SelectedValue works when you have column returns 1 value from column. If your column is aggregating , lets say 71 is for multiple people on given selection it will return NULL value and hence your if statement will never get true and returns "Not Working"

     

    See screenshot for the reference.

     

    You might need to use other aggregate function or include further granuality on your table selection to have desired results.

     

    Regards

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi cheezy ,

     

    Please share some sample data if you don't have any Confidential Information.

     

    Best Regards,

    Jay