Forum Discussion
Ganesh99
Jan 12, 2023Copper Contributor
Switch function in Access is not evaluating more than 2 conditions
Hello All, Assume a table has columns Description, SO and Region. Column5: Switch([description]=[SO],"L2L",[region]="Bangalore" Or "ROK","K2L",[region]="East" Or "West" Or "North" Or "South",...
- Jan 12, 2023
Hi,
The syntax for the OR operator is wrong. You would have to repeat the full comparison for every value, i.e. [region]="Bangalore" Or [region]="ROK" etc. With more than 1 value it's easier to use the IN operator. If I understand your intention correctly, then this should work:
Switch([description]=[SO],"L2L",[region] IN ("Bangalore", "ROK"),"K2L",[region] IN ("East", "West","North","South"),"L2L")
Servus
Karl
****************
Access Bug Trackers
Access News
Access DevCon
arnel_gp
Steel Contributor
Column5: Switch([description]=[SO],"L2L",[region]="Bangalore" Or [region]="ROK","K2L",[region]="East" Or ,[region]="West" Or ,[region]="North" Or,[region]= "South","L2L", True, Null)
Ganesh99
Jan 13, 2023Copper Contributor
Hi Arnel,
Thanks for this.
I tried your version. It is returning "L2L" even for those cases where Description is not same as SO.
Regards
Ganesh
Thanks for this.
I tried your version. It is returning "L2L" even for those cases where Description is not same as SO.
Regards
Ganesh