# Filter Alarm Status Table

**URL:** <https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 14, 2024, 8:00pm UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239 "2024-10-14T20:00:08Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 14, 2024, 9:12pm UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239/3 "2024-10-14T21:12:31Z")

</div>

Okay, first, posting only screen shots of code can be frustrating, you should post the formatted code. If you want to provide a screen shot to give more context that's great but you should always post any code in question as preformatted text.

See:

> [@Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831):
>
> This thread is intended as a short help file for all those struggling to post formatted code on the forum. Code block formatting Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the \</\> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting. [How to post code] Note that all the \</\> button does is add three backticks ``` on the line before the code block and anot…

Second, you don't need to use the `get()` function, you can just reference the property directly.

Third, the comment above your conditional does not match what the logic is doing. It says that you want to display alarms without a matching display path, but the logic is doing the opposite of that.

Finally, your conditional can be cleaned up and optimized so you're minimizing the amount of time it takes to filter the table.

```python
def filterAlarm(self, alarmEvent):

	# Retrieve the Grupo property from the alarm event
	grupo = alarmEvent.displayPath
	
	# Correctly retrieve the checkbox selections from the view's custom properties
	nodo1Selected = self.custom.Nodo1
	nodo3Selected = self.custom.Nodo3
	nodo5Selected = self.custom.Nodo5
	
	possibleGrupo = ['Nodo 1','Nodo 3','Nodo 5']
	# If no checkboxes are selected, show alarms with no Grupo value
	if not (any([nodo1Selected,nodo3Selected,nodo5Selected])) and grupo not in possibleGrupo:
		return True
	# Show alarms that match the selected nodes
	elif any([grupo == 'Nodo 1' and nodo1Selected,grupo == 'Nodo 3' and nodo3Selected,grupo == 'Nodo 5' and nodo5Selected]):
		return True
	return False

```

The use of the `any()` built-in allows for short-circuiting the evaluation, so as soon as a checkbox is seen as being true it will return instead of evaluating all options.

Once a return is evaluated, no code beyond that point will be processed, I have factored out all of your `else return False` statements to the end of the conditional. In python an `else if` condition is signaled by the `elif` keyword, so I have used here as well. These changes I believe make the code much more readable.

---

_[View the full topic](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239)._
