Splunk Search

How can I reorder this table so the column B data represents the month prior?

ASISH_9
Engager

I have the following table:

Month                 Value
September             12
October               78
November              88
December              132

I want to display the value of October in September, November in October and so on. The final output should look like this:

Month                 Value
September             78
October               88
November              132
December              Value of January

How can this be achieved? Please help. Thanks in advance.

0 Karma

cmerriman
Super Champion

try adding this to the end (assuming Value keeps growing):

...|sort 0 Value|streamstats window=1 current=f values(Month) as prevMonth|rename prevMonth as Month|where isnotnull(Month)

if Value doesn't keep growing and it is already sorted how you need it, just remove the sort command.

DalJeanis
Legend

Rather than values(), I'd generally use last() -- or even better, latest(), if there is a _time field --but they are functionally equivalent in this case.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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