Question

Help with counting totals

  • 20 December 2018
  • 3 replies
  • 49 views

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.


3 replies

Userlevel 7
Badge +1

@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!

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

Userlevel 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) ;;

}

Reply