You have to make sure your variables have the correct value, using the correct Let or Set to declare a variable. Certainly you can use a string in a where statement. Please see attached example. If it is not working and you cannot solve the problem by debugging yourself, then please either make an example demonstrating your problem or attach your dashboard. Could be something more going on (i.e. the functions you use to create variables, the script itself, or other things that can't be predicted).
The script I used in case you can't access the dashboard is: