Hello fellow Splunkers,
Pretty new to using case statements in Splunk and I've run into an odd problem that I have no clue how to resolve. I'm trying to get counts based on departments. In some cases we'd like to pull numbers for specific sub-departments within a broader department; ie; mathematics and mathematics - research and mathematics - analysis - etc...
What I noticed is that whenever I try to get a total count for items that have child departments those counts get omitted from the parent department's total count.
ie: let's say I have several departments, some will have sub-departments and others won't. From a numbers standpoint, I only need specific one's for the sub-departments. At the same time, I need to get numbers for parent and all child-depts that fall under that parent.
mathematics
mathematics - research
mathematics - research adv
mathematics - analysis
mathematics - analysis tier2
mathematics - analysis tier3
mathematics - analysis tier4
english
science
|searchHere
|eval deptSummary = case(
dept LIKE "%mathematics - analysis%", "Mth_A",
dept LIKE "%mathematics - analysis tier%", "Mth_A_t",
dept LIKE "%english%", "Eng",
dept LIKE "%mathematics%", "Mth",
dept LIKE "%science%, ""Scn")
|stats count(dept) by deptSummary
The problem I've run into is that the parents counts don't include numbers for any that are captured by the other LIKE statements.
So if I have:
mathematics - 10
mathematics - research - 1
mathematics - research adv - 5
mathematics - analysis - 5
mathematics - analysis tier1 - 10
mathematics - analysis tier2 - 1
mathematics - analysis tier3 - 1
dept LIKE "%mathematics%", "Mth", --->would come out to a total of 33
dept LIKE "%mathematics - analysis%", "Mth_A", --> would come out to 17
dept LIKE "%mathematics - analysis tier%", "Mth_A_t", --> would come out to 12
What's happening is that counts captured by the LIKE statements with the sub-departments aren't included in the parent level LIKE statement. So if I cant to see the total for the parent department I'm left with just the events that didn't match any of the other LIKE statements. The counts for the departments which have no sub-departments are accurate, so it seems to just be a problem with the tiered matching.
Any suggestions how to go about this?
... View more