Splunk Search

How to display percent in a stacked bar chart?

jip31
Motivator

hi

I try to display percent in my bar chart like this but it doesnt works

 

| chart count as total over sig_application by sig_transaction 
| eval total=0 
| foreach count* 
    [ eval total=total + <<FIELD>>] 
| foreach count* 
    [ eval <<FIELD>>=round((<<FIELD>>/total)*100,1)] 
| fields - total

 

is anybody can help please?

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| chart count as total over sig_application by sig_transaction 
| rename * as count*
| rename countsig_transaction as sig_transaction
| addtotals fieldname=total count* 
| foreach count* 
    [ eval <<FIELD>>=round((<<FIELD>>/total)*100,1)] 
| fields - total

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What fields do you get from 

| chart count as total over sig_application by sig_transaction
0 Karma

jip31
Motivator

what do you mean exactly?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What are the fields/column called?

Your foreach count* assumes that that they all start with count?

0 Karma

jip31
Motivator

you are right

it's not the case...

it miss | rename * as count*

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| chart count as total over sig_application by sig_transaction 
| rename * as count*
| rename countsig_transaction as sig_transaction
| addtotals fieldname=total count* 
| foreach count* 
    [ eval <<FIELD>>=round((<<FIELD>>/total)*100,1)] 
| fields - total
0 Karma

jip31
Motivator

thanks to your help but i think its not a good idea to use it because its not really explicit in my chart

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

So you also have a column called countsig_transaction?

0 Karma

jip31
Motivator

I just have a column countsig_app

0 Karma
Get Updates on the Splunk Community!

Financial Services Industry Use Cases, ITSI Best Practices, and More New Articles ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Splunk Federated Analytics for Amazon Security Lake

Thursday, November 21, 2024  |  11AM PT / 2PM ET Register Now Join our session to see the technical ...

Splunk With AppDynamics - Meet the New IT (And Engineering) Couple

Wednesday, November 20, 2024  |  10AM PT / 1PM ET Register Now Join us in this session to learn all about ...