I'm a bit unsure how to go about this, but essentially I'd like to create a new field for each value contained in an existing field.
I have a field that we'll call name containing several hundred entries. I'd like to create a new value for each field in name containing the count of all entries associated with that name.
In pseudo-code, I imagine it working something like this:
stats count(eval(name=n)) as "n" creating a new n for every value contained in name.
Is this possible?
Can I loop a statement, populating n with a new value each time?
That did the trick. Thanks!
This creates a new problem were all but the top 11 names get lumped into an Other category, but this certainly answers my initial question.
I can't go into too much detail, but I'll do my best.
My input contains 3 columns: id, name, and created date.
The output I'm looking for is: a row for each month of the year, with a column name, and a count of ids per name/month.
Sort of like this:
Name Name2 Name3 Jan-14 1 0 3 Feb-14 2 4 4 Mar-14 0 0 1
(I've got all the time conversion and sorting figured out, I'm just having trouble sorting by both month and name (I can easily do one or the other but not both) so I figured if each name had a field I could just count those fields by month)
While that almost works, the end goal (which I haven't yet mentioned, apologies) is to chart this data in a line graph with a line for each name.
As far as I can tell, I can't do this unless I'm able to break out each name into it's own field and ensure there is only 1 row per date.