# Alteryx Designer

Andy Uttley, Alteryx ACE, makes music with Alteryx | Math + Music
SOLVED

## Counting True in a column of Bool (again)

Highlighted
5 - Atom

My input is a table of 30 columns of bools.

I want to get 30 numbers counting how many trues there are in those 30 columns.

In Python with Numpy this is super easy, in SQL too.

However, with Alteryx I do not understand how to do so in an elegant way.

In the summarize tool there is a count Non Null but there is no count Non Zero (or Count True), how is this possible?

I am new to Alteryx and it's hard for me to get over such a missing essential feature.

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Counting-True-and-False-in-a-column-of...

However, I'm not sure if that solves my problem.

A first solution, not very elegant IMO, is casting every 30 columns to Bytes through the Formula tool. However, it takes forever to do so because it is not possible to copy paste a formula inside the formula tool (another thing I cannot get my head around).

Another solution is to use the summarize tool via the group by then sum method, but I could not get it to work since in the screenshot of that page the bool column is already a byte but mine is a bool.

Then there is the other solution with the frequency table and I did not try it because at this point I do not want the frequencies I want only to count the number of True values.

As an example, here is a little test table of 2 columns and 5 rows:

col1  col2

True True

True False

False True

False False

True False

col1 has 3 True and col2 has 2 True, that what I want to get.

Highlighted
12 - Quasar

Hi, @data_chose

Can you provide a sample file?

Happy to help if you can.

Cheers.

Highlighted
5 - Atom

Here is a little test table of 2 columns and 5 rows:

col1  col2

True True

True False

False True

False False

True False

col1 has 3 True and col2 has 2 True, that what I want to get.

-------

I copy pasted this in the OP. I do not know how to delete this message, sorry.

Highlighted
12 - Quasar

Sure thing, @data_chose

Try this.

I used Multi-field Tool so that you can apply to multiple Columns at once.

Please mark as an acceptable solution + like, if it works for you.

The workflow is attached.

Cheers!

Highlighted
5 - Atom

Meanwhile, I found another slightly easier way to cast bools to Byte: the Select tool.

Highlighted
12 - Quasar

You're most welcome @data_chose !

Cheers.

Highlighted
12 - Quasar

Yes! @data_chose

The Select Tool is an excellent go-to option if you don't have too many columns and if your flow will not be dynamically introducing new columns (that also need to be cast as Bool).

I love and resonate with your easier way.

It's "Good-enough," and you don't need to be detracted by the search for "Perfect."

Cheers!

Labels