Solved

# Counting total of different textual values in a column

• 15 views

• Member
• 3 replies

The dataset has a colum with three distinct values - <10, >10 and No.

How do I get the count the total for each value?

icon

Best answer by Eric_Lyons 7 November 2020, 03:10

Hi @Minesh Barot

If we wanted to use table calculations, we could use an if statement to determine if the line item in the column is equal to our distinct value, if it is, we can return a 1, else we return a 0. Then, we wrap this in a sum to get the total count. We would have to do this for each value.

An alternative to do this in the Explore, would be to use a custom measure, where we create a filtered measure that counts a field if the filter condition is true. This would be similar to a traditional filtered measure we can define in LookML.

The other option would be to create a type: count measure and just select your column as a dimension and the type count measure. This way we get a count grouped by the values in the dimension column.

We can also do this in the explore, if we create a custom measure type count distinct on a primary key and then select the column you would like to group the count by.

Please let us know if you have any questions!

Thanks,

Eric

View original

Userlevel 1

Hi @Minesh Barot

If we wanted to use table calculations, we could use an if statement to determine if the line item in the column is equal to our distinct value, if it is, we can return a 1, else we return a 0. Then, we wrap this in a sum to get the total count. We would have to do this for each value.

An alternative to do this in the Explore, would be to use a custom measure, where we create a filtered measure that counts a field if the filter condition is true. This would be similar to a traditional filtered measure we can define in LookML.

The other option would be to create a type: count measure and just select your column as a dimension and the type count measure. This way we get a count grouped by the values in the dimension column.

We can also do this in the explore, if we create a custom measure type count distinct on a primary key and then select the column you would like to group the count by.

Please let us know if you have any questions!

Thanks,

Eric