<?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 Re: How to display one to one mapping between fields in stats command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-one-to-one-mapping-between-fields-in-stats/m-p/741028#M240522</link>
    <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;values&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;list&lt;/FONT&gt; functions display results in lexicographic order and destroy any potential relationship among the fields.&amp;nbsp; One solution is use &lt;FONT face="courier new,courier"&gt;mvzip&lt;/FONT&gt; to combine fields, group the results, then unzip the fields.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=okta or index=network
| iplocation (src_ip)
| eval tuple = mvzip(src_ip, mvzip(deviceName, mvzip(City, Country)))
| stats values(tuple) by user, index
| eval fields = split(tuple, ",")
| eval src_ip = mvindex(fields, 0), deviceName=mvindex(fields,1), City=mvindex(fields, 2), Country=mvindex(fields,3)&lt;/LI-CODE&gt;&lt;P&gt;A better approach might be to perform the &lt;FONT face="courier new,courier"&gt;iplocation&lt;/FONT&gt; command after &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=okta or index=network
| stats values(src_ip) as src_ip by user, index
| mvexpand src_ip
| iplocation (src_ip)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Mar 2025 15:23:45 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2025-03-06T15:23:45Z</dc:date>
    <item>
      <title>How to display one to one mapping between fields in stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-one-to-one-mapping-between-fields-in-stats/m-p/740541#M240451</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp; how can i use stats command to one to one mapping between fields .&amp;nbsp; I have tried "list" function and "values" function both but results are not expected.&lt;BR /&gt;Example:&amp;nbsp;we are consolidating data from 2 indexes and both indexes have same fields of interests ( user, src_ip)&amp;nbsp;&lt;BR /&gt;Base query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=okta or index=network
| iplocation (src_ip)
|stats values(src_ip) values(deviceName) values(City) values(Country) by user, index&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Results:&lt;BR /&gt;We get something like this&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;user&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;index&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;src_ip&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;DeviceName&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;Country&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;John_smith&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;okta&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;10.0.0.1&lt;BR /&gt;192.178.2.24&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;laptop01&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;USA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;John_smith&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;network&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;198.20.0.14&lt;BR /&gt;64.214.71.89&lt;BR /&gt;64.214.71.90&lt;BR /&gt;71.29.100.90&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;laptop01&lt;BR /&gt;laptop02&lt;BR /&gt;server01&lt;BR /&gt;My-CloudPC&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;USA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Expected results:&lt;BR /&gt;How to map which &lt;STRONG&gt;src_ip&lt;/STRONG&gt; is coming from which &lt;STRONG&gt;Devicename&lt;/STRONG&gt;?&amp;nbsp; We want to align the &lt;STRONG&gt;Devicename&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;in same sequence as per the src_ip ?&lt;BR /&gt;&lt;BR /&gt;If i use &lt;STRONG&gt;list&lt;/STRONG&gt; instead of &lt;STRONG&gt;values&lt;/STRONG&gt; in my stats,&amp;nbsp; it shows duplicates like this for src_ip and deviceName. Even doing a &lt;STRONG&gt;|dedup src_ip&lt;/STRONG&gt; is not helping&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="neerajs_81_0-1741004055398.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/37940iAE6BF846AAFFC397/image-size/large?v=v2&amp;amp;px=999" role="button" title="neerajs_81_0-1741004055398.png" alt="neerajs_81_0-1741004055398.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Hope clear.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Mar 2025 12:14:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-one-to-one-mapping-between-fields-in-stats/m-p/740541#M240451</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2025-03-03T12:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to display one to one mapping between fields in stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-one-to-one-mapping-between-fields-in-stats/m-p/741028#M240522</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;values&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;list&lt;/FONT&gt; functions display results in lexicographic order and destroy any potential relationship among the fields.&amp;nbsp; One solution is use &lt;FONT face="courier new,courier"&gt;mvzip&lt;/FONT&gt; to combine fields, group the results, then unzip the fields.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=okta or index=network
| iplocation (src_ip)
| eval tuple = mvzip(src_ip, mvzip(deviceName, mvzip(City, Country)))
| stats values(tuple) by user, index
| eval fields = split(tuple, ",")
| eval src_ip = mvindex(fields, 0), deviceName=mvindex(fields,1), City=mvindex(fields, 2), Country=mvindex(fields,3)&lt;/LI-CODE&gt;&lt;P&gt;A better approach might be to perform the &lt;FONT face="courier new,courier"&gt;iplocation&lt;/FONT&gt; command after &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=okta or index=network
| stats values(src_ip) as src_ip by user, index
| mvexpand src_ip
| iplocation (src_ip)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2025 15:23:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-one-to-one-mapping-between-fields-in-stats/m-p/741028#M240522</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2025-03-06T15:23:45Z</dc:date>
    </item>
  </channel>
</rss>

