This question already has an answer here:
I have attempted to write an expression for hours now by looking through these forums.
I want to write if this column equals Blank, than this column equals blank.
If defect_typ = A_FC THEN Defect_Nam = Fatigue Cracking
I can get a return from multiple codes, but here is an example of one I did:
CASE WHEN defect_typ LIKE '%A_FC%' THEN 'Fatigue Cracking' ELSE 'other'
No matter what code I use it fills my entire defect_nam column with Fatigue Cracking or other, and if I try to do multiple, (which I need to create multiple conditional rules) it will fill the column with a mash up of the returns (fatigueCrackingBlockcrackingPatching) but I need to figure out how to do one before I can move on.
I am an ArcMap Vet and to get the result I want in Esri I would use the following script
def Defect(defect_types_code): if (defect_types_code == "A_LC"): return "Linear Cracking" elif (defect_types_code == "M_PS"): return "Parking Bumper Damage" elif (defect_types_code == "M_RB"): return "Rebuild/Replace Catch Basin" elif (defect_types_code == "M_RD"): return "Ramp Damage else: return "N/A"
How do I write this in QGIS?
I was linked to another question with answers to help, "Elseif Conditional Statement in QGIS Field Calculator,"but the outcome of this code filled my defect_nam with all Nulls.