# How to get the count of the non-repeated values in a specific column inside a table?

**URL:** <https://forum.inductiveautomation.com/t/how-to-get-the-count-of-the-non-repeated-values-in-a-specific-column-inside-a-table/76853>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 25, 2023, 11:36am UTC](https://forum.inductiveautomation.com/t/how-to-get-the-count-of-the-non-repeated-values-in-a-specific-column-inside-a-table/76853 "2023-07-25T11:36:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![samer\_samy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/samer_samy/32/52910_2.png) [@samer\_samy](https://forum.inductiveautomation.com/u/samer_samy)\
**Post date:** [July 25, 2023, 11:36am UTC](https://forum.inductiveautomation.com/t/how-to-get-the-count-of-the-non-repeated-values-in-a-specific-column-inside-a-table/76853/1 "2023-07-25T11:36:06Z")

</div>

How to get the count of the Non repeated values in a specific column inside a table?  
i can only get all table count by using ---\> value.getRowCount()

---

<div class="post-metadata">

**Author:** ![JoeF](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@JoeF](https://forum.inductiveautomation.com/u/JoeF)\
**Post date:** [July 25, 2023, 11:56am UTC](https://forum.inductiveautomation.com/t/how-to-get-the-count-of-the-non-repeated-values-in-a-specific-column-inside-a-table/76853/2 "2023-07-25T11:56:05Z")

</div>

I enjoy using ds.getColumnAsList() ( **ds** is a dataset) and then the python set() constructor to get unique values in a column. You can count the number of unique values with len() after that. If what you are looking for is more complicated then that, you would need to write a specific function.

`len(set(ds.getColumnAsList(ds.getColumnIndex("column_name"))))`

---

<div class="post-metadata">

**Author:** ![Usman\_Ashraf](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/usman_ashraf/32/43168_2.png) [@Usman\_Ashraf](https://forum.inductiveautomation.com/u/Usman_Ashraf)\
**Post date:** [July 25, 2023, 12:25pm UTC](https://forum.inductiveautomation.com/t/how-to-get-the-count-of-the-non-repeated-values-in-a-specific-column-inside-a-table/76853/3 "2023-07-25T12:25:32Z")

</div>

In my opinion, a custom script will do the job. A sample script to extract the values will be as follow:

```auto
lst = self.getSibling("Table").props.data
	
	element_count = {}
	
	for element in lst:
		element_count[int(element['population'])] = element_count.get(int(element['population']), 0) + 1
	# Count non-duplicate values
	non_duplicates_count = sum(1 for count in element_count.values() if count == 1)
	self.getSibling("Label").props.text = non_duplicates_count

```

The first line is extracting the data from the table, and the last line is showing the non-duplicate count in a label text. Please feel free to change these lines as per your visual.

My sample visual for the script testing looks like this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/1/61668baf1931f5b6252a63f0b2a2cb83b892bc6d.png)

Thanks.

---

<div class="post-metadata">

**Author:** ![samer\_samy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/samer_samy/32/52910_2.png) [@samer\_samy](https://forum.inductiveautomation.com/u/samer_samy)\
**Post date:** [July 25, 2023, 12:32pm UTC](https://forum.inductiveautomation.com/t/how-to-get-the-count-of-the-non-repeated-values-in-a-specific-column-inside-a-table/76853/4 "2023-07-25T12:32:02Z")

</div>

Thanks alot
