<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to create strcat field names with spaces? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-strcat-field-names-with-spaces/m-p/642718#M222608</link>
    <description>&lt;P&gt;I'm working with two similar, but not quite the same datasets and I want to create a table which displays data from either of the data sets in the same column.&amp;nbsp; For example, one dataset has the field Source_Name and the other dataset has the field "Source Name".&amp;nbsp; While I understand that spaces in field names is evil and should eb avoided, I have no control over the source data and am stuck working with what I have.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the past, when trying to mash two datasets together like this, I have relied on strcat to give me a consistent field name to work with ala:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;some search 
| strcat FieldA FieldB FieldAB&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since only FieldA or FieldB will be populated, based on which dataset the record is from, I will get the appropriate entry in the resultant FieldAB.&amp;nbsp; However, I've run into an issue this time as the spaces in the field name of one of my datasets is giving me trouble. I've tried:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| "Source Name" Source_Name SourceName&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This treats the "Source Name" as a string literal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| 'Source Name' Source_Name SourceName&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This returns nothing for the case where 'Source Name' exists and 'Source_Name' does not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| \"Source Name\" Source_Name SourceName&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This returns nothing for the case where 'Source Name' exists and 'Source_Name' does not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do have a workaround where I rename the "Source Name" field to Source-Name and then do the strcat using that field.&amp;nbsp; This works; but, I am wondering if there is a cleaner solution?&amp;nbsp; Is there a way to reference a field name with a space in it, with the strcat command?&amp;nbsp; Alternatively, is there just a better way of selectively displaying a different field, depending on which one exists in a dataset, specifically at search time?&lt;/P&gt;</description>
    <pubDate>Tue, 09 May 2023 18:40:32 GMT</pubDate>
    <dc:creator>jlaska</dc:creator>
    <dc:date>2023-05-09T18:40:32Z</dc:date>
    <item>
      <title>How to create strcat field names with spaces?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-strcat-field-names-with-spaces/m-p/642718#M222608</link>
      <description>&lt;P&gt;I'm working with two similar, but not quite the same datasets and I want to create a table which displays data from either of the data sets in the same column.&amp;nbsp; For example, one dataset has the field Source_Name and the other dataset has the field "Source Name".&amp;nbsp; While I understand that spaces in field names is evil and should eb avoided, I have no control over the source data and am stuck working with what I have.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the past, when trying to mash two datasets together like this, I have relied on strcat to give me a consistent field name to work with ala:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;some search 
| strcat FieldA FieldB FieldAB&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since only FieldA or FieldB will be populated, based on which dataset the record is from, I will get the appropriate entry in the resultant FieldAB.&amp;nbsp; However, I've run into an issue this time as the spaces in the field name of one of my datasets is giving me trouble. I've tried:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| "Source Name" Source_Name SourceName&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This treats the "Source Name" as a string literal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| 'Source Name' Source_Name SourceName&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This returns nothing for the case where 'Source Name' exists and 'Source_Name' does not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| \"Source Name\" Source_Name SourceName&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This returns nothing for the case where 'Source Name' exists and 'Source_Name' does not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do have a workaround where I rename the "Source Name" field to Source-Name and then do the strcat using that field.&amp;nbsp; This works; but, I am wondering if there is a cleaner solution?&amp;nbsp; Is there a way to reference a field name with a space in it, with the strcat command?&amp;nbsp; Alternatively, is there just a better way of selectively displaying a different field, depending on which one exists in a dataset, specifically at search time?&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 18:40:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-strcat-field-names-with-spaces/m-p/642718#M222608</guid>
      <dc:creator>jlaska</dc:creator>
      <dc:date>2023-05-09T18:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to create strcat field names with spaces?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-strcat-field-names-with-spaces/m-p/642722#M222611</link>
      <description>&lt;P&gt;I prefer the coalesce function for this scenario.&amp;nbsp; It populates a field with the first non-null argument provided.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Field = coalesce(FieldA, FieldB)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 09 May 2023 19:07:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-strcat-field-names-with-spaces/m-p/642722#M222611</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-05-09T19:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create strcat field names with spaces?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-strcat-field-names-with-spaces/m-p/642724#M222612</link>
      <description>&lt;P&gt;That's perfect, thank you.&lt;/P&gt;&lt;P&gt;As a note for anyone else looking at this, for fields with spaces in the names, it's necessary to put the field name in single quotes.&amp;nbsp; E.g.:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval SourceName=coalesce('Source Name', Source_Name)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 09 May 2023 19:18:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-strcat-field-names-with-spaces/m-p/642724#M222612</guid>
      <dc:creator>jlaska</dc:creator>
      <dc:date>2023-05-09T19:18:45Z</dc:date>
    </item>
  </channel>
</rss>

