<?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 Getting blank rows when comparing two JSON data sets with some common and unique keys in them in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Getting-blank-rows-when-comparing-two-JSON-data-sets-with-some/m-p/681025#M55770</link>
    <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;I am comparing two JSON data sets with respect to values of some nested keys in them.&lt;/P&gt;
&lt;P&gt;The comparison is working fine except that at the end I am getting some blank rows with no data for them in the columns except the diff column that I am inserting.&lt;/P&gt;
&lt;P&gt;I am including the query that I am using. However, since I am using appendcols in this, so the data sets returned by the search commands would be as below respectively:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data1={
\"Sugar\": {
\"prod_rate\" : \"50\",
\"prod_qual\" : \"Good\"
},
\"Rice\": {
\"prod_rate\" : \"80\",
\"prod_qual\" : \"OK\"
},
\"Potato\": {
\"prod_rate\" : \"87\",
\"prod_qual\" : \"OK\"
}
}

data2="{
\"Sugar\": {
\"prod_rate\" : \"50\",
\"prod_qual\" : \"Good\"
},
\"Wheat\": {
\"prod_rate\" : \"50\",
\"prod_qual\" : \"Good\"

}
}"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The actual query with proper search command in place is actually returning some blank rows. How can I remove them from display ?&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index = data1

| eval grain_name = json_array_to_mv(json_keys(data1))
|mvexpand grain_name
|eval data = json_extract(data1, grain_name), qual = json_extract(data, "prod_qual")
|table grain_name, qual
| appendcols [ search index=data2| eval grain_name2 = json_array_to_mv(json_keys(data2))
| mvexpand grain_name2
| eval data2 = json_extract(data2, grain_name2), qual2 = json_extract(data2, "prod_qual")]
|eval diff = if(match (qual, qual2), "Same", "NotSame")
|table grain_name, qual, diff&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 18 Mar 2024 14:01:51 GMT</pubDate>
    <dc:creator>splunk_dev</dc:creator>
    <dc:date>2024-03-18T14:01:51Z</dc:date>
    <item>
      <title>Getting blank rows when comparing two JSON data sets with some common and unique keys in them</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Getting-blank-rows-when-comparing-two-JSON-data-sets-with-some/m-p/681025#M55770</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;I am comparing two JSON data sets with respect to values of some nested keys in them.&lt;/P&gt;
&lt;P&gt;The comparison is working fine except that at the end I am getting some blank rows with no data for them in the columns except the diff column that I am inserting.&lt;/P&gt;
&lt;P&gt;I am including the query that I am using. However, since I am using appendcols in this, so the data sets returned by the search commands would be as below respectively:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data1={
\"Sugar\": {
\"prod_rate\" : \"50\",
\"prod_qual\" : \"Good\"
},
\"Rice\": {
\"prod_rate\" : \"80\",
\"prod_qual\" : \"OK\"
},
\"Potato\": {
\"prod_rate\" : \"87\",
\"prod_qual\" : \"OK\"
}
}

data2="{
\"Sugar\": {
\"prod_rate\" : \"50\",
\"prod_qual\" : \"Good\"
},
\"Wheat\": {
\"prod_rate\" : \"50\",
\"prod_qual\" : \"Good\"

}
}"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The actual query with proper search command in place is actually returning some blank rows. How can I remove them from display ?&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index = data1

| eval grain_name = json_array_to_mv(json_keys(data1))
|mvexpand grain_name
|eval data = json_extract(data1, grain_name), qual = json_extract(data, "prod_qual")
|table grain_name, qual
| appendcols [ search index=data2| eval grain_name2 = json_array_to_mv(json_keys(data2))
| mvexpand grain_name2
| eval data2 = json_extract(data2, grain_name2), qual2 = json_extract(data2, "prod_qual")]
|eval diff = if(match (qual, qual2), "Same", "NotSame")
|table grain_name, qual, diff&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 18 Mar 2024 14:01:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Getting-blank-rows-when-comparing-two-JSON-data-sets-with-some/m-p/681025#M55770</guid>
      <dc:creator>splunk_dev</dc:creator>
      <dc:date>2024-03-18T14:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Getting blank rows when comparing two JSON data sets with some common and unique keys in them</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Getting-blank-rows-when-comparing-two-JSON-data-sets-with-some/m-p/681033#M55771</link>
      <description>&lt;P&gt;The appendcols command just appends columns in whatever order they are returned in with no respect for the values in the "common" fields, so, your comparison is like comparing apples with oranges, or in your case wheat with rice. Is this what you really want to do?&lt;/P&gt;&lt;P&gt;You could use stats to combine the values from each search like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = data1

| eval grain_name = json_array_to_mv(json_keys(data1))
|mvexpand grain_name
|eval data = json_extract(data1, grain_name), qual = json_extract(data, "prod_qual")
|table grain_name, qual
| append [ search index=data2
| eval grain_name = json_array_to_mv(json_keys(data2))
| mvexpand grain_name
| eval data2 = json_extract(data2, grain_name), qual2 = json_extract(data2, "prod_qual")]
| stats values(qual) as qual values(qual2) as qual2 by grain_name
|eval diff = if(match (qual, qual2), "Same", "NotSame")
|table grain_name, qual, diff&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 18 Mar 2024 13:48:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Getting-blank-rows-when-comparing-two-JSON-data-sets-with-some/m-p/681033#M55771</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-03-18T13:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Getting blank rows when comparing two JSON data sets with some common and unique keys in them</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Getting-blank-rows-when-comparing-two-JSON-data-sets-with-some/m-p/681074#M55773</link>
      <description>&lt;P&gt;You are correct, I want to compare apple with apple (or sugar with sugar).&lt;/P&gt;&lt;P&gt;Your query has removed the blank rows.&lt;/P&gt;&lt;P&gt;But the comparison is failing. It is saying every thing is Notsame.&lt;/P&gt;&lt;P&gt;However here the sugar prod_qual is same. In the real data sets there are many values which are same and few are not same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 16:54:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Getting-blank-rows-when-comparing-two-JSON-data-sets-with-some/m-p/681074#M55773</guid>
      <dc:creator>splunk_dev</dc:creator>
      <dc:date>2024-03-18T16:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Getting blank rows when comparing two JSON data sets with some common and unique keys in them</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Getting-blank-rows-when-comparing-two-JSON-data-sets-with-some/m-p/681085#M55774</link>
      <description>&lt;P&gt;The problem with fake, made-up data is when it does not accurately represent your real data. We can only provide solutions based on the data you have given. If it does not represent your data closely enough,&amp;nbsp; our solutions may not work with your actual data. Please try to provide representative examples (anonymised as appropriate) which demonstrate why the proposed solution does not work for you.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 18:23:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Getting-blank-rows-when-comparing-two-JSON-data-sets-with-some/m-p/681085#M55774</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-03-18T18:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Getting blank rows when comparing two JSON data sets with some common and unique keys in them</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Getting-blank-rows-when-comparing-two-JSON-data-sets-with-some/m-p/681113#M55775</link>
      <description>&lt;P&gt;Well, the data is little simplified but the structure is same.&lt;/P&gt;&lt;P&gt;Actually , I am trying to compare not only prod_qual but other values as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now it is working&lt;/P&gt;&lt;P&gt;I am comparing both prod_qual and prod_rate hence I have modified your query as below,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = data1

| eval grain_name = json_array_to_mv(json_keys(data1))
|mvexpand grain_name
|eval data = json_extract(data1, grain_name), rate= json_extract(data, "prod_rate"), qual = json_extract(data, "prod_qual")
|table grain_name, qual
| append [ search index=data2
| eval grain_name = json_array_to_mv(json_keys(data2))
| mvexpand grain_name
| eval data2 = json_extract(data2, grain_name),rate2= json_extract(data2, "prod_rate") qual2 = json_extract(data2, "prod_qual")]
| stats values(qual) as qual values(qual2) as qual2  values(rate) as rate values(rate2) as rate2 by grain_name
|eval diff = if(match (qual, qual2), "Same", "NotSame")
|eval diff2 = if(diff == "Same", if(rate==rate2, "Same", "NotSame"), "NotSame")
|table grain_name, qual, rate, diff2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 07:36:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Getting-blank-rows-when-comparing-two-JSON-data-sets-with-some/m-p/681113#M55775</guid>
      <dc:creator>splunk_dev</dc:creator>
      <dc:date>2024-03-19T07:36:34Z</dc:date>
    </item>
  </channel>
</rss>

