When 1 is not equal to 1

I am using a Data Viewer to filter items. When I select the item in the list, I get an id and then iterates through a table comparing the id in the table row with the entered id.

I have added some debugging labels which show that even though each value shows as 1, they are deemed not equal.

2023-12-15 21 17 59

Would appreciate any assistance.

Thanks
Steve

One does not equal one when “1 " and “1” are compared or " 1” and “1” are compared, etc.

You can try adding “bookends” to the variables when displaying them in labels by joining a separator character like “#” in front and back of the value using the Join block in the Text drawer.

That way, if you see #1#, you know that represents “1” in your data source but if you see # 1 #" then you know that represents " 1 ".

Finally, you’re comparing string values, not numbers. To compare numeric values, you need to convert the strings to numbers by adding zero to them. It may not matter when comparing equalities but if you for example tried to determine if “18” was greater than “2” (“18” > “2” ?), you might get unexpected results since “18” comes before “2” alphabetically.

Thanks @tatiang ,

My understanding was that once the variables were initialised as “0”, they would be seen as numbers throughout.

Anyway, I added a block to add 0 to the variables.

The strange thing is that at first I added 0 to both variables and it worked. I then wanted to figure out which of the 2 was the offending variable, so I only added 1 to SelectedRetailerId and the code worked. Just to be sure I changed it to rowRetailerId (not expecting it to work) but it did.

So I am a bit confused as it seems that while one or both of them are invalid types, it doesn’t matter which one I correct will get the code to work.

Thoughts??

Thanks as always for your insight.

I’m not sure that’s true.

Can you show the blocks you used for those tests? I can’t really picture it from your description.