I also have a similar problem in my case i don't want "undefined" data from my filter , i just altered your code above but am getting error, Please see the attached screenshot. can u help me on this?
A Where clause can't be used in a chart expression, only in load statements in the script.
And "undefined" is 9 characters long, not 1. So you need to use 9 as the second parameter in the Left function.