Forum Discussion
xiumi_hou
6 years agoPost Partisan
Need help for dax function
Dear all, the below dax gave me wrong result, can someone helpe me figure it out?
What I really want is:
If 'Cases'[Cases_cstm.referred_by_c])="Self" then report "5"
If 'Cases'[Cases_cstm.referred_by_c])="Practitioner" then
if 'prac_practitioners'[type])="general_practitioner" report 1
if 'prac_practitioners'[type])="nurse_practiitoner"," report 2
if 'prac_practitioners'[type])="psychiatrist", report 3
If 'Cases'[Cases_cstm.referred_by_c] is blank, then report " "
My dax:
Referral_Source_Type = IF(SELECTEDVALUE('Cases'[Cases_cstm.referred_by_c])="Self","5",
if(SELECTEDVALUE('Cases'[Cases_cstm.referred_by_c])="Practitioner", switch(
True(),
SELECTEDVALUE('prac_practitioners'[type])="general_practitioner","1",
SELECTEDVALUE('prac_practitioners'[type])="nurse_practiitoner","2",
SELECTEDVALUE('prac_practitioners'[type])="psychiatrist","3"
), " ")
)
HI xiumi_hou
Your formula works in a measure, if you are want to create a column, please adjust the formula as below:
Referral_Source_Type = IF ( 'Cases'[Cases_cstm.referred_by_c] = "Self", "5", IF ( 'Cases'[Cases_cstm.referred_by_c] = "Practitioner", SWITCH ( TRUE (), 'prac_practitioners'[type] = "general_practitioner", "1", 'prac_practitioners'[type] = "nurse_practiitoner", "2", 'prac_practitioners'[type] = "psychiatrist", "3" ), " " ) )Regards,
Lin
2 Replies
- v-lili6-msftCommunity Support
HI xiumi_hou
Your formula works in a measure, if you are want to create a column, please adjust the formula as below:
Referral_Source_Type = IF ( 'Cases'[Cases_cstm.referred_by_c] = "Self", "5", IF ( 'Cases'[Cases_cstm.referred_by_c] = "Practitioner", SWITCH ( TRUE (), 'prac_practitioners'[type] = "general_practitioner", "1", 'prac_practitioners'[type] = "nurse_practiitoner", "2", 'prac_practitioners'[type] = "psychiatrist", "3" ), " " ) )Regards,
Lin