Expression Evaluation - bug or user error?

I’ve run into an interesting problem that could be a bug or a user error…

I’m using the COUNT function… (note I’m not showing all the syntax for the COUNT function, just the problematic part)

When I evaluate expression #1 it works, when I try to generalize it to expression #2 it fails…
#1: COUNT LocationName == “London”

#2: Marker (ProdLoc = London); COUNT LocationName == ProdLoc

Any help appreciated… The second expression will save a ton of work, if I can use it instead of the first…

It’s rather difficult to figure out what’s wrong with your syntax if you don’t show us your actual syntax…

See image

If I replace ProdLoc with “London” in the expression it works.

Does every piece you’re trying to count have this ProdLoc marker? If so, I’m afraid I have no idea why that isn’t working. I think Brent is the expert on Beanshell Expressions, perhaps he can chime in?

Mark posted a “BeanShell Puzzler” bug report… That linked to a bug report that showed how to fix this…

The trick is to use /"$ProdLoc$/"

I don’t know why it works, but it does… :stuck_out_tongue:

This illustrates a fundamental Software Development Paradigm…

Even a monkey with a hammer can (eventually) churn out working code…

One more problem solved!
Thanks all…

I think I can explain why it works: $ProdLoc$ gets replaced by the contents of ProdLoc on the executing piece before the Count function is run, while ProdLoc doesn’t get replaced until the Count function is running, so it gets replaced by the contents of ProdLoc on the piece being counted, instead.