Splunk Search

Can you give me some help with the coalesce command?

jip31
Motivator

hi,

When I execute the query below

index="x" sourcetype="WinEventLog:Microsoft-Windows-Diagnostics-Performance/Operational"

I can display a field called "OpCode". This field has many values and I want to display one of them.

Sometimes this field is in english, sometimes in French, sometimes in Spanish and sometimes in German.

So I need to use "coalesce" like this

| eval 'Boot_Degradation'=coalesce('Boot_Degradation','Détérioration du démarrage','Información del arranque','Startbeeinträchtigung') 
| table OpCode

but it doesn't work.

could you help me please???

0 Karma
1 Solution

vnravikumar
Champion

Hi @jip31

Try this, it will take first not null value

| makeresults 
   | eval OpCode=coalesce(null(),"Détérioration du démarrage","Información del arranque","Startbeeinträchtigung") | table OpCode

View solution in original post

0 Karma

FrankVl
Ultra Champion

'Boot_Degradation','Détérioration du démarrage','Información del arranque','Startbeeinträchtigung'

Are those your field names? Or your field values? The coalesce command takes field names as parameters, and returns the first non-null field.

0 Karma

nickhills
Ultra Champion

Coalesce is not the command you need here. Try this:

| makeresults 
| eval OpCode="Boot_Degradation,Détérioration du démarrage,Información del arranque,Startbeeinträchtigung"

| makemv delim="," OpCode
| eval OpCode=mvindex(OpCode, 0)

The first two lines make some sample data - hopefully I have interpreted this right?
The last two lines make the field multivalued, and then pick the first (0) value in the mv list and returns that value.

If you wanted french swap the 0 for a 1 etc

You full search would probably be something like this:

index="x" sourcetype="WinEventLog:Microsoft-Windows-Diagnostics-Performance/Operational"| makemv delim="," OpCode
| eval OpCode=mvindex(OpCode, 0)|table OpCode
If my comment helps, please give it a thumbs up!

vnravikumar
Champion

Hi @jip31

Try this, it will take first not null value

| makeresults 
   | eval OpCode=coalesce(null(),"Détérioration du démarrage","Información del arranque","Startbeeinträchtigung") | table OpCode
0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...