I'm not sure there is anything really wrong with a roundabout approach like that. Sometimes with Splunk, what seems simple might take a little work to get there. The nice part is that you can almost always get there!
That said, here is another way (I think). It's a bit cumbersome as well, but just a different approach. The main hurdle is that you need the distinct count for multis. But instead of stats maybe a dedup will work.
| eval class=case(type <=3, 0, type > 3, 1)
| eval id = if(id="NULL",null,id)
| dedup keepempty=t class id
| eval metric = case (class=0 AND isnull(id),"Class0Singles",class=1 AND isnull(id),"Class1Singles",class=0 AND isnotnull(id),"Class0Multis",class=1 AND isnotnull(id),"Class1Multis")
| stats count by metric
So still eval the class field, but also set the id to literally null if it's "NULL". Then dedup on the class and id but keep those null fields around. At this point you should have events that are unique to class and id if id isn't null (multis)..and then all of the events if id is null (singles)
At that point, do an eval on each event to create the metric field. And finally count those by that field. You should still be getting a count all singles by class and only have a count of unique ids for each class.
I think that's right? Again, still a bit ugly even if it does work, but just a different trip to the same destination.
... View more