Splunk Search

Compare 2 calculated values in a chart

Declan123
Explorer

Hi All,

I am trying to calculate 2 values by multiplication and then compare these 2 values on a column/bar chart. 

My query to calculate the 2 values is:

source="transaction file.csv" Description="VDP-WWW.AMAZON" | rename "Debit Amount" AS DebitAmount | eval totalprime=DebitAmount*59 | eval totalvalue=286*5.99

 

However I am having trouble displaying them on a chart to compare their values. I would ideally like them to both be on the X axis and have the Y axis as a generic 'total value' or similar just so I can easily see how one value compares against the other. 

When I attempt to do this with a query like the below,  I have to select 1 field as X axis and 1 as Y axis which leads the chart being incorrect. 

source="transaction file.csv" Description="VDP-WWW.AMAZON" | rename "Debit Amount" AS DebitAmount | eval totalprime=DebitAmount*59 | eval totalvalue=286*5.99 | chart sum(totalprime) as prime, sum(totalvalue) as value

Declan123_0-1723630603757.png

 

I want totalvalue as a column and totalprime as another column, next to each other. To allow me to easily compare the total amount of each next to each other. 

Can anyone help with this? Thanks.

 

Labels (4)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @Declan123 ,

did you trid the transpose command?

try something like this:

source="transaction file.csv" Description="VDP-WWW.AMAZON" 
| rename "Debit Amount" AS DebitAmount
| eval totalprime=DebitAmount*59 
| eval totalvalue=286*5.99
| stats sum(totalprime) AS totalprime sum(totalvalue) AS totalvalue
| transpose

you'll have something like this:

gcusello_0-1723631657963.png

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @Declan123 ,

did you trid the transpose command?

try something like this:

source="transaction file.csv" Description="VDP-WWW.AMAZON" 
| rename "Debit Amount" AS DebitAmount
| eval totalprime=DebitAmount*59 
| eval totalvalue=286*5.99
| stats sum(totalprime) AS totalprime sum(totalvalue) AS totalvalue
| transpose

you'll have something like this:

gcusello_0-1723631657963.png

Ciao.

Giuseppe

Declan123
Explorer

Thank you Giuseppe, that was exactly what I was looking to achieve. 

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!

From Data to Insight: Announcing the Winners of the Splunk Dashboard Contest

Hi Splunkers, First off, thank you to everyone who participated in our very first From Data to Insight: The ...

Splunk Developers: Construct Your Future at the .conf26 Builder Bar

Calling all Splunk architects, platform admins, and app developers: the site is open, and the blueprints are ...

Quick connection discovery mode for forwarders

When a Splunk forwarder loses connectivity to its indexers, it does not always reconnect immediately. In many ...