<?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 can I compute value based on group by values in timechart? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639607#M221639</link>
    <description>&lt;P&gt;Wow, thanks for your solution! It worked like charm!&lt;/P&gt;</description>
    <pubDate>Wed, 12 Apr 2023 09:07:43 GMT</pubDate>
    <dc:creator>Sathiya123</dc:creator>
    <dc:date>2023-04-12T09:07:43Z</dc:date>
    <item>
      <title>How can I compute value based on group by values in timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639598#M221630</link>
      <description>&lt;P&gt;| eval vm_unit=case(vmSize="Standard_F16s_v2",2,vmSize="Standard_F8s_v2",1,vmSize="Standard_F4s",0.5,vmSize="Standard_F2s_v2",0.25)&lt;BR /&gt;| bin _time span=1h&lt;BR /&gt;| stats values(vm_unit) as vm_unit values(location) as location by _time id&lt;BR /&gt;| timechart span=1h usenull=true sum(vm_unit)-case(location="westus2",2245,location="centralus",2146,location="northeurope",624,location="germanywestcentral",620) as vm_count by location&lt;BR /&gt;| fillnull value=0&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 07:50:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639598#M221630</guid>
      <dc:creator>Sathiya123</dc:creator>
      <dc:date>2023-04-12T07:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compute value based on group by values in timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639599#M221631</link>
      <description>&lt;P&gt;it says no results found. But the below query works without the case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| eval vm_unit=case(vmSize="Standard_F16s_v2",2,vmSize="Standard_F8s_v2",1,vmSize="Standard_F4s",0.5,vmSize="Standard_F2s_v2",0.25)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| bin _time span=1h&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| stats values(vm_unit) as vm_unit values(location) as location by _time id&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| timechart span=1h usenull=true sum(vm_unit) as vm_count by location&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| fillnull value=0&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 07:52:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639599#M221631</guid>
      <dc:creator>Sathiya123</dc:creator>
      <dc:date>2023-04-12T07:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compute value based on group by values in timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639602#M221634</link>
      <description>&lt;P&gt;The subtraction with the case is not valid in the timechart command.&lt;/P&gt;&lt;P&gt;It is not clear what you are trying to do here.&lt;/P&gt;&lt;P&gt;Do you wish to subtract a value from the sum for the location based on the location, or subtract a value from the vm_unit based on the location prior to summing for each location, or something else?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 08:30:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639602#M221634</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-04-12T08:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compute value based on group by values in timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639604#M221636</link>
      <description>&lt;P&gt;As you discovered, operators are not allowed outside of stats functions in a stats command. &amp;nbsp;Why not calculate it after stats?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval vm_unit=case(vmSize="Standard_F16s_v2",2,vmSize="Standard_F8s_v2",1,vmSize="Standard_F4s",0.5,vmSize="Standard_F2s_v2",0.25)
| bin _time span=1h
| stats values(vm_unit) as vm_unit values(location) as location by _time id
| timechart span=1h usenull=true sum(vm_unit) as vm_count by location
| eval vm_count = vm_count - case(location="westus2",2245,location="centralus",2146,location="northeurope",624,location="germanywestcentral",620)
| fillnull value=0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 08:38:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639604#M221636</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-04-12T08:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compute value based on group by values in timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639606#M221638</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;vm_count doesn't exist after timechart&lt;/P&gt;&lt;P&gt;Either do it this way:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval vm_unit=case(vmSize="Standard_F16s_v2",2,vmSize="Standard_F8s_v2",1,vmSize="Standard_F4s",0.5,vmSize="Standard_F2s_v2",0.25)
| bin _time span=1h
| stats values(vm_unit) as vm_unit values(location) as location by _time id
| timechart span=1h usenull=true sum(vm_unit) as vm_count by location
| fillnull value=0
| eval westus2 = westus2 - 2245
| eval centralus = centralus - 2146
| eval northeurope = northeurope - 624
| eval germanywestcentral = germanywestcentral - 620&lt;/LI-CODE&gt;&lt;P&gt;or this way&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval vm_unit=case(vmSize="Standard_F16s_v2",2,vmSize="Standard_F8s_v2",1,vmSize="Standard_F4s",0.5,vmSize="Standard_F2s_v2",0.25)
| bin _time span=1h
| stats values(vm_unit) as vm_unit values(location) as location by _time id
| stats sum(vm_unit) as vm_count by _time location
| eval vm_count = vm_count - case(location="westus2",2245,location="centralus",2146,location="northeurope",624,location="germanywestcentral",620)
| timechart span=1h usenull=true sum(vm_count) as vm_count by location
| fillnull value=0&lt;/LI-CODE&gt;&lt;P&gt;Although, to be fair, I am not sure what this is trying to achieve&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 08:55:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639606#M221638</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-04-12T08:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compute value based on group by values in timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639607#M221639</link>
      <description>&lt;P&gt;Wow, thanks for your solution! It worked like charm!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 09:07:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-compute-value-based-on-group-by-values-in-timechart/m-p/639607#M221639</guid>
      <dc:creator>Sathiya123</dc:creator>
      <dc:date>2023-04-12T09:07:43Z</dc:date>
    </item>
  </channel>
</rss>

