Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
cheezy
Helper I
Helper I

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")
 
 

test.png

 

aany ideas? thanks

 
 
4 REPLIES 4
Anonymous
Not applicable

Hi @cheezy ,

 

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

 

Best Regards,

Jay

FarhanAhmed
Community Champion
Community 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.SelectedValue.png

 

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

 

Regards







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




amitchandak
Super User
Super User

@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")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.