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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...