Repeater filter with OR logic

repeater-widget

#1

I’m pretty new to Axure and I think I may just be missing something with my syntax here, but I’m trying to setup a repeater filter and it’s not working. I could use some help.

I have 4 columns in the table which can have one of 3 possible values: 0, 1, or 2. I have set up a filter that I want to use to show only rows that have a value of 1 or 2 in any of these 4 columns.

Here is the expression I’ve written:
[[Item.HR!=0 || Item.MAP!=0 || Item.SP02!=0 || Item.RR!=0 || Item.TEMP!=0]]

Problem is, when I click the button that applies this filter, it doesn’t actually filter anything. It definitely is doing something - I get a few seconds of the machine working hard to process the command - but no rows end up getting filtered out.

I tried escaping the zero with single quotes and double quotes, but no change. I also tried adding spaces between the logical operands, still no change.

[[Item.HR != '0' || Item.MAP != '0' || Item.SP02 != '0' || Item.RR != '0' || Item.TEMP != '0']]

Where have I gone wrong here?


#2

Please upload your .rp file.


#3

This is going to sound like a nit-pick, but “SPO2” is spelled with an O rather than a zero. I’m pointing this out not to be a jerk but because if you have the repeater column labeled differently that would be a problem. (Whether it’s the problem I have no way of knowing, but it occurs to me that if that expression returned a null or an error, then neither one of those would equal zero, so maybe?)

HTH
Jeff


#4

Hi Jeff,

Not a nit-pick at all, that’s a good observation. I did just check, and the repeater table had SP02 (SP-zero-2) in the column heading, so that was not the issue. I’ve gone ahead and corrected it anyways. :slight_smile:

Here is the RP file if anyone wants to take a look. This is my first project in Axure, so let me know if something I’m doing is glaringly wrong.

Thank you!

Project_210403_1.rp (257.9 KB)


#5

Hi!

Filters can be tricky. This filter is working properly.

A filter is basically a true/false test that is applied to each row of the repeater. If the expression is true for a particular row, that row is shown; otherwise, it’s hidden.

You are combining multiple expressions with OR (the double-pipe characters). When using OR, if just one of the expressions is true for a row, then the entire expression is true for a row. It’s similar to English in a way:

"I want a car that isn't red or isn't blue."

A yellow car will suit you, but a red car or a blue car won’t. You don’t even have to look past the first condition (“isn’t red”) to know that a red car is not for you.

The confusing thing is that in English, you can also say,

"I want a car that isn't red AND isn't blue."

…and you might interpret it to mean the same thing. But in fact no single-color car exists that will satisfy you with the criteria above, because no single-color car in the world both isn’t red and isn’t blue. A yellow car isn’t red and blue. A blue car isn’t red and blue.

Your filter is asking to show rows whose “HR” column value isn’t equal to 0, among other things. HR is not 0 for any row, so regardless of what the other expressions say, the filter’s combined expressions will be true for all rows, because the first expression is true for all rows.

If you were to use AND (&&) instead of OR, then every expression in the filter would have to be true in order for the entire expression to be true. But even then, this filter would not weed out any rows, because each individual expression (e.g., TEMP doesn’t equal 0, HR doesn’t equal 0) is true for all rows.

As an experiment, set “Art Vandaly’s” TEMP value to 0, and all other queried values to non-zero. You’ll notice that when you apply the filter, Art Vandaly is still there. Then change change all of your ORs to ANDs. You’ll notice that he’s gone.

What are you intending the filter to do?


#6

Josephxbric - thanks for taking the time to responsd. You helped me figure out the issue - I actually wanted to filter on HRA, MAPA, etc. not HR, MAP, etc.

After reading your description, I realized my mistake and corrected my expression to reference the right columns. All is working now.

Thank you!!