<?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: Separate Multivalued fields in XQL in Cortex XDR Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/separate-multivalued-fields-in-xql/m-p/563549#M5440</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/325956"&gt;@WilliamValente&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;We may need the full XQL to understand the cascading stages more, but you can try the below options and let me know if any works for you:&lt;BR /&gt;&lt;BR /&gt;1- If the values are duplicate in the field, you can limit the output of the&amp;nbsp;arrayexpand stage by using the limit switch as to one output for example , something like this&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;| arrayexpand Object_Values limit 1&lt;BR /&gt;&lt;BR /&gt;2- The second option here (but will show the values separated in one line)is to use the&amp;nbsp;&amp;nbsp;“arraystring” function, so something like this (where we use comma for example to separate the values):&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;| alter hostname = arraystring (Object_Values, ", ")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I hope that helps and shed some light!&lt;BR /&gt;&lt;BR /&gt;Please feel free to mark this as a solution if it helps resolve the request&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Z&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Oct 2023 15:46:48 GMT</pubDate>
    <dc:creator>zarnous</dc:creator>
    <dc:date>2023-10-30T15:46:48Z</dc:date>
    <item>
      <title>Separate Multivalued fields in XQL</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/separate-multivalued-fields-in-xql/m-p/563533#M5439</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need some help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two fields with multiple values and I need to separate there values into separates lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My fields are like these:&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="WilliamValente_0-1698676200912.png" style="width: 400px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/54742iF2E1BC92C9057A8A/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="WilliamValente_0-1698676200912.png" alt="WilliamValente_0-1698676200912.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;My goal is to have 1 line with each of the results:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;field = value&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;I tried using the arrayexpand command, but it ends up duplicating all rows of all values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2023 14:31:58 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/separate-multivalued-fields-in-xql/m-p/563533#M5439</guid>
      <dc:creator>WilliamValente</dc:creator>
      <dc:date>2023-10-30T14:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Multivalued fields in XQL</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/separate-multivalued-fields-in-xql/m-p/563549#M5440</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/325956"&gt;@WilliamValente&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;We may need the full XQL to understand the cascading stages more, but you can try the below options and let me know if any works for you:&lt;BR /&gt;&lt;BR /&gt;1- If the values are duplicate in the field, you can limit the output of the&amp;nbsp;arrayexpand stage by using the limit switch as to one output for example , something like this&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;| arrayexpand Object_Values limit 1&lt;BR /&gt;&lt;BR /&gt;2- The second option here (but will show the values separated in one line)is to use the&amp;nbsp;&amp;nbsp;“arraystring” function, so something like this (where we use comma for example to separate the values):&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;| alter hostname = arraystring (Object_Values, ", ")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I hope that helps and shed some light!&lt;BR /&gt;&lt;BR /&gt;Please feel free to mark this as a solution if it helps resolve the request&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Z&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2023 15:46:48 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/separate-multivalued-fields-in-xql/m-p/563549#M5440</guid>
      <dc:creator>zarnous</dc:creator>
      <dc:date>2023-10-30T15:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Multivalued fields in XQL</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/separate-multivalued-fields-in-xql/m-p/563555#M5441</link>
      <description>&lt;P&gt;Hi Zarnous,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried your query, but It is not the result that I want.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;The command arrayexpand with limit 1, return only the first value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The command arraystring just concatenate the values with ",". I need each line with field = value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the command arryexpand without limit, they duplicate the value, like this:&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="WilliamValente_0-1698682752384.png" style="width: 400px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/54748i53BDCC9A9E1ACC96/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="WilliamValente_0-1698682752384.png" alt="WilliamValente_0-1698682752384.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My XQL is:&lt;BR /&gt;&lt;BR /&gt;dataset = trend&lt;BR /&gt;| alter alert_name = json_extract(_alert_data, "$.alert_name"),&lt;BR /&gt;priority_score = json_extract(_alert_data, "$.trendmicrovisiononexdrpriorityscore"),&lt;BR /&gt;alert_description = json_extract(_alert_data, "$.alert_description"),&lt;BR /&gt;investigation_status = json_extract(_alert_data, "$.trendmicrovisiononexdrinvestigationstatus"),&lt;BR /&gt;impact_scope = regextract(impactScope, "\"entityValue\\":([^,]+)"),&lt;BR /&gt;impact_scope_name = regextract(impactScope, "\"name\\":([^,]+)"),&lt;BR /&gt;ips = regextract(impactScope, "\"ips\\":([^,]+)"),&lt;BR /&gt;mitretechniqueid = regextract(matchedrules, "\"mitreTechniqueIds\\":([^,]+)"),&lt;BR /&gt;object_field = regextract(indicators, "\"field\\":([^,]+)"),&lt;BR /&gt;object_value = regextract(indicators, "\"value\\":([^,]+)")&lt;BR /&gt;| arrayexpand object_field &lt;BR /&gt;| arrayexpand object_value &lt;BR /&gt;| fields _time, severity, alert_name, priority_score, investigation_status, mitretechniqueid, impact_scope_name, description, ips, object_field, object_value, id, workbenchLink&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2023 16:21:20 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/separate-multivalued-fields-in-xql/m-p/563555#M5441</guid>
      <dc:creator>WilliamValente</dc:creator>
      <dc:date>2023-10-30T16:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Multivalued fields in XQL</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/separate-multivalued-fields-in-xql/m-p/563579#M5444</link>
      <description>&lt;P&gt;Thank you for sharing the query, unfortunately i cant replicate it in my tenant since you are using a custom dataset that i dont have, but looking at the query logic, and specially the fields&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;object_field = regextract(indicators, "\"field\\":([^,]+)"),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;object_value = regextract(indicators, "\"value\\":([^,]+)")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;I see they are extracted in JSON Like format and i also see that it is possible to have the same object field as associated with one or more object value, i can see that as an expected query result , hence seeing multiple values matching same field, otherwise if you try to dedup the filed you will loose lots of the values associated with it.&lt;BR /&gt;&lt;BR /&gt;Please correct me if i misunderstood the use case here!&lt;BR /&gt;&lt;BR /&gt;Thanks&amp;nbsp;&lt;BR /&gt;Z&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2023 17:29:32 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/separate-multivalued-fields-in-xql/m-p/563579#M5444</guid>
      <dc:creator>zarnous</dc:creator>
      <dc:date>2023-10-30T17:29:32Z</dc:date>
    </item>
  </channel>
</rss>

