Forum Discussion
Multiple IF/AND for text fields
- 2 years ago
Turned I had a couple of issues!
1. I needed to select "new column" not "new measure" in order to pull from my data
2. I had left a comma at the end
3. I spelt severity wrong and had copy pasted it (duh)
In the end it looked like this, but with all 16 variables, and it worked 🙂
Column =SWITCH(true(),[Defect Severity]="low"&&[Defect Occurrence]="low","Acceptable",[Defect Severity]="Low"&&[Defect Occurrence]="Medium","Acceptable")
It looks like you are on the right track with using the SWITCH function, but there are some syntax errors in your DAX code. Also, it seems like there might be a mix-up in the order of your conditions. Here's a corrected version of your DAX formula:
Defect Acceptability =
SWITCH (
TRUE (),
AND([Defect Severity] = "Low", [Defect Occurrence] = "Low"), "Acceptable",
AND([Defect Severity] = "Low", [Defect Occurrence] = "Medium"), "Acceptable",
AND([Defect Severity] = "Low", [Defect Occurrence] = "High"), "Acceptable",
AND([Defect Severity] = "Low", [Defect Occurrence] = "Very High"), "Justify",
// Add similar conditions for other severity levels
AND([Defect Severity] = "Medium", [Defect Occurrence] = "Low"), "Your_Result_For_Medium_Low",
AND([Defect Severity] = "Medium", [Defect Occurrence] = "Medium"), "Your_Result_For_Medium_Medium",
AND([Defect Severity] = "Medium", [Defect Occurrence] = "High"), "Your_Result_For_Medium_High",
AND([Defect Severity] = "Medium", [Defect Occurrence] = "Very High"), "Your_Result_For_Medium_Very_High",
// Repeat for other severity levels
// Add a default case if none of the conditions match
"Other_Result"
)
Make sure to replace "Your_Result_For_X_Y" with the actual result you want for each combination of severity and occurrence. Also, include conditions for other severity levels as needed.
Note: I assumed that your severity and occurrence values are text strings. If they are numerical, you should remove the quotation marks around the values in the conditions.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.