Hello Alteryx community! New to SQL here... Scenario: some patients are on AntiPsychotic medications as well as non-AntiPsychotic medication. If a client is on Anti-Psychotic Medication I want the result to be "Client on Antipsychotic Medication" even if only 1 of their 10 medications is an AntiPsychotic... As well as if they are on no AntiPsychotics, I want it to be "Not on AntiPsychotic Medication"My first formula here works, but, the second one does not... What do you recommend?
Solved! Go to Solution.
Your second if formula doesn't work because there is no ELSE statement
Hi @MaryCann
You should be able to simplify it to:
IF [Clauses] THEN "Client on Antipsychotic Medication"
ELSE "Client not on Antipsychotic Medication"
ENDIF
Correct! Although having the [Client_ID] part in there may not work, as will that field contain the "Antipsychotic Medication" wording if it's an ID field?
Client ID does not contain the word "Antipsychotic Medication", but, since the extract is based on client services, meaning 1 client ID could be repeated covering many rows (a new service date=a new row), and the one medication in the medication column that the client is receiving may only state, like "ARIPiprazole" , and the other medications may be Aspirin, or Ibuprofen, etc. in with different service dates. I felt the need to build a correlation...
Does that make sense? I know sometimes the paragraph in my head makes sense, but, I have no idea if anyone else understands it!
Makes sense!
You can drop that part of the clause as the formula will tag each row with them being on the drug (or not). Try it and run and see if you get the expected results and let me know :)
Quick newby question for confirmation: would that make the denominator the number of rows, or the number of clients?
Hi Mary,
I was able to get to what you are looking to accomplish, by doing the following. I would recommend 2 things though; first, of writing an IF statement, have the list of Antipsychotic Medications in another input. Second, for better performance, I would assign 0 for those patients who are not on Antipsychotic drugs and 1 for those who are on it, once all members/clients are assigned, I would rename the 0 and 1s. This will ensure better performance, especially as your list of clients will increase. I attached the workflow for your convenience as well.
**If this solves the issue, please click on the like below" thank you!