Dashboards & Visualizations

Subtracting time charts

priyangshupal
Engager

I have a timechart from the command timechart span=1d count by skill1 which looks like this:

_timeVALUE1VALUE2VALUE3VALUE4
2021-09-15772431728
2021-09-16801046522

 

And another timechart from the command timechart span=1d count by skill2 which looks like this:

_timeVALUE1VALUE2VALUE3VALUE4
2021-09-15702001012
2021-09-1656875411

 

I want to create a new timechart which should have skill1's values - skill2's values. As follows:

_timeVALUE1VALUE2VALUE3VALUE4
2021-09-15743716
2021-09-1614171111

 

I tried using the command:

 

timechart span=1d count by skill1-skill2

 

But it won't work.

 

Any suggestions on how to create the new timechart?

Labels (3)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

Alternatively if you can share your data selection part of the search, it can probably be done using subsearches to join the two data sets together.

0 Karma

bowesmana
SplunkTrust
SplunkTrust

You can do this type of timechart with eval and then calc the differences afterwards, but that my not work unless you know and can code in all the values of skill

| makeresults count=1000
| eval _time=_time-(random() % 7)*86400
| eval skill1=mvindex(split("Value1,Value2,Value3,Value4",","), random() % 4)
| eval skill2=mvindex(split("Value1,Value2,Value3,Value4",","), random() % 4)
| timechart span=1d sum(eval(if(skill1="Value1", 1, 0))) as s1v1 sum(eval(if(skill1="Value2", 1, 0))) as s1v2 sum(eval(if(skill1="Value3", 1, 0))) as s1v3 sum(eval(if(skill1="Value4", 1, 0))) as s1v4 sum(eval(if(skill2="Value1", 1, 0))) as s2v1 sum(eval(if(skill2="Value2", 1, 0))) as s2v2 sum(eval(if(skill2="Value3", 1, 0))) as s2v3 sum(eval(if(skill2="Value4", 1, 0))) as s2v4
| eval v1=s1v1-s2v1, v2=s1v2-s2v2, v3=s1v3-s2v3, v4=s1v4-s2v4
| table _time v*

Just paste in this to the search window

 

0 Karma

priyangshupal
Engager

Hi @bowesmana 

This is producing results, but the difference is wrong

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 ...