Help with counting totals


(Gerardo) #1

Hi, I have some problems with some data I would like to put in a visualization. For example, I have the following:

Orders Cancel Reason

SATURATION
COURIER_NOT_ASSIGNED
NO_PAYMENT
SATURATION
SATURATION
NO_PAYMENT

I would like to get the following:

Orders Cancel Reason Count

SATURATION 3
NO_PAYMENT 2
COURIER_NOT_ASSIGNED 1

I have tried to solve this but I just started using Looker so I have some problems with this. Any help would be greatly appreciated. Thank you.


(Izzy) #2

@gflores1092
I bet a simple measure of type: count would help you out!

A super basic example is just

measure: count {
    type: count
  }

If you spin that up in your view file and then return Orders Cancel Reason and Count in an explore, you should get

Orders Cancel Reason Count

SATURATION 3
NO_PAYMENT 2
COURIER_NOT_ASSIGNED 1

as your result!


(Gerardo) #3

Hi @izzy, thanks for your help. It is finally solved after a long time trying as I’m new to Looker. Thanks!


(James Nestler) #4

Another way to do this would be to create a measure with the count function built into the sql parameter. This approach would be slightly more complex than using the “type: count” argument.

It would look something like this:

measure: countofstuff {
type: number
sql: count(${TABLE}.item_name) ;;
}