Splunk Search

Addtotals in table issue

splunkreal
Influencer

Hello, I'd like to add totals to remove the two-lines result per row, how to do? Thanks.

* If this helps, please upvote or accept solution if it solved *
Tags (2)
0 Karma
1 Solution

jkat54
SplunkTrust
SplunkTrust

See if this works:

| multisearch 
[search index=d2i sourcetype=D2I_Fichesconsolidees typ_stat=*_TOTAL | rename counter as total_count]
[search index=d2i sourcetype=D2I_Fichesconsolidees typ_stat=*_PERMIS | rename counter as perm_count]
| stats sum(total_count) as total_count sum(perm_count) as perm_count by type_fiche

Note, you need to use the different "e" in Ficheconsolidees as I dont have this "e" on my keyboard.

Even better though:

index=d2i sourcetype=D2I_Fichesconsolidees (typ_stat=*_TOTAL OR typ_stat=*PERMIS) 
| eval total_count=if(typ_stat=*_TOTAL,counter,null()) 
| eval perm_count=if(typ_stat=*_PERMIS,counter,null()) 
| stats sum(total_count) as total_count sum(perm_count) as perm_count by type_fiche

View solution in original post

splunkreal
Influencer

"Error in 'eval' command: Regex: nothing to repeat"

* If this helps, please upvote or accept solution if it solved *
0 Karma

davebrooking
Contributor

Take a look at the like and match functions in the Search Reference documentation, you should probably be able to use either to accomplish the solution proposed by jkat54.

I could attempt a solution, but you won't be learning anything that way. If you are still having problems having read the documentation, post the searches you've tried and how they're failing to produce the desired results. If you are successful it would be nice to see the query you decided to use.

Dave

0 Karma

splunkreal
Influencer

Thanks Dave, anyway I've already got a solution provided by Michael.

* If this helps, please upvote or accept solution if it solved *
0 Karma

davebrooking
Contributor

My comment was referring to the "Error in 'eval' command: Regex: nothing to repeat" message. If you have a solution that matches your needs then Happy Splunking.

Dave

0 Karma

jkat54
SplunkTrust
SplunkTrust

See if this works:

| multisearch 
[search index=d2i sourcetype=D2I_Fichesconsolidees typ_stat=*_TOTAL | rename counter as total_count]
[search index=d2i sourcetype=D2I_Fichesconsolidees typ_stat=*_PERMIS | rename counter as perm_count]
| stats sum(total_count) as total_count sum(perm_count) as perm_count by type_fiche

Note, you need to use the different "e" in Ficheconsolidees as I dont have this "e" on my keyboard.

Even better though:

index=d2i sourcetype=D2I_Fichesconsolidees (typ_stat=*_TOTAL OR typ_stat=*PERMIS) 
| eval total_count=if(typ_stat=*_TOTAL,counter,null()) 
| eval perm_count=if(typ_stat=*_PERMIS,counter,null()) 
| stats sum(total_count) as total_count sum(perm_count) as perm_count by type_fiche

splunkreal
Influencer

| multisearch
[search index=d2i sourcetype=D2I_Fichesconsolidées typ_stat=_TOTAL | rename counter as total_count]
[search index=d2i sourcetype=D2I_Fichesconsolidées typ_stat=
_PERMIS | rename counter as perm_count]
| stats sum(total_count) as total_count sum(perm_count) as perm_count by typ_fiche

Dear Michael, first search worked (just a mistake at 'typ_fiche'), thanks a lot!

Second search was giving an error at eval :

Error in 'eval' command: The expression is malformed. An unexpected character is reached at '*_TOTAL,counter,null())'.

* If this helps, please upvote or accept solution if it solved *
0 Karma

jkat54
SplunkTrust
SplunkTrust

OK great, but you want to run just one search for this as it is more efficient, uses less cpu, memory, etc. Try this too please:

 index=d2i sourcetype=D2I_Fichesconsolidees (typ_stat=*_TOTAL OR typ_stat=*PERMIS) 
 | eval total_count=if(match(typ_stat,"*_TOTAL"),counter,null()) 
 | eval perm_count=if(match(typ_stat,"*_PERMIS"),counter,null()) 
 | stats sum(total_count) as total_count sum(perm_count) as perm_count by typ_fiche
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

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

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...