Splunk Search

Having sum function issues after entering multiple names on index

nsantiago17
Explorer

Hi,
I'm having a problem trying to sum all the "marcador05" and the others by Country when I put one country name on the index- it works fine, but when I enter more than one it seems like something is wrong, my example below:

(CORRECT)

Country Primeira Semana Segunda Semana  Quinzenal   Terceira Semana Quarta Semana   Fim do Mes
Finland    0                  0              0          0                0              0

(WRONG)

JOB_NAME    Primeira Semana Segunda Semana  Quinzenal   Terceira Semana Quarta Semana   Fim do Mes
Norway    0               0              0          0                 0             0
Finland     1                 0              0          0                 0             0

.

| eval marcador05 = if(COMP_DIA = 01 or COMP_DIA = 02 or COMP_DIA = 03 or COMP_DIA = 04 or COMP_DIA = 05,if(isOutlier = 1,1,0),0)
    | eval marcador10 = if(COMP_DIA = 06 or COMP_DIA = 07 or COMP_DIA = 08 or COMP_DIA = 09 or COMP_DIA = 10,if(isOutlier = 1,1,0),0)
    | eval marcador15 = if(COMP_DIA = 11 or COMP_DIA = 12 or COMP_DIA = 13 or COMP_DIA = 14 or COMP_DIA = 15,if(isOutlier = 1,1,0),0)
    | eval marcador20 = if(COMP_DIA = 16 or COMP_DIA = 17 or COMP_DIA = 18 or COMP_DIA = 19 or COMP_DIA = 20,if(isOutlier = 1,1,0),0)
    | eval marcador25 = if(COMP_DIA = 21 or COMP_DIA = 22 or COMP_DIA = 23 or COMP_DIA = 24 or COMP_DIA = 25,if(isOutlier = 1,1,0),0)
    | eval marcador31 = if(COMP_DIA = 26 or COMP_DIA = 27 or COMP_DIA = 28 or COMP_DIA = 29 or COMP_DIA = 30 or COMP_DIA = 31,if(isOutlier = 1,1,0),0)
    | stats sum(marcador05) as "Primeira Semana", sum(marcador10)  as "Segunda Semana", sum(marcador15)  as Quinzenal, sum(marcador20)  as "Terceira Semana", sum(marcador25)  as "Quarta Semana", sum(marcador31)  as "Fim do Mes" by Country

Can someone help me, and if you have some idea to do the "if loop" better than mine,
please feel free to share.
Thanks

0 Karma
Get Updates on the Splunk Community!

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...

AI for AppInspect

We’re excited to announce two new updates to AppInspect designed to save you time and make the app approval ...

App Platform's 2025 Year in Review: A Year of Innovation, Growth, and Community

As we step into 2026, it’s the perfect moment to reflect on what an extraordinary year 2025 was for the Splunk ...