Splunk Dev

How to merge text in Splunk table?

ashanka
Explorer

Have a table like this , how

Type Country

Reporting US
reporting CAN
Reporting IND
COnsolidated US
Consolidate CAN
Consolidated IND

How do i display as

Type Country

Reporting US
CAN
IND
Consolidated US
CAN
IND

Tags (1)
0 Karma

anmolpatel
Builder

@ashanka as such:

| makeresults 
| eval _raw = "Type Country
Reporting US
reporting CAN
Reporting IND
COnsolidated US
Consolidate CAN
Consolidated IND" 
| multikv forceheader=1 
| eval Type_new = upper(substr(Type, 0, 1)) + lower(substr(Type, 2)) 
| eval Type = case(match(Type_new, "Reporting"), "Reporting", match(Type_new, "Consolidate(d)?"), "Consolidated")
| stats list(Country) as Country By Type

This will return:
alt text

0 Karma

manjunathmeti
SplunkTrust
SplunkTrust

Try this. This will display results exactly as you want.

| eval Type=if(Country="US", Type, Country), Country=if(Country="US", Country, "") 
| table Type, Country

If you want to group Country by Type, then use stats.

| stats values(Country) as Country by Type

Sample query:

| makeresults 
| eval _raw=" Type Country
Reporting US
reporting CAN
Reporting IND
Consolidated US
Consolidate CAN
Consolidated IND" 
| multikv forceheader=1 
| eval Type=if(Country="US", Type, Country), Country=if(Country="US", Country, "") 
| table Type, Country
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...