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!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...