<?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 Is it possible to test derived fields in set expressions? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Is-it-possible-to-test-derived-fields-in-set-expressions/m-p/1791540#M61906</link>
    <description>&lt;P&gt;Can I put a dimension derived with Aggr in the left side of a set expression?&amp;nbsp; It's not working for me right now, but I'm not sure why.&lt;/P&gt;&lt;P&gt;For each product, I have the current stock and list of orders (with dates).&amp;nbsp; I'm trying to get the date for each product when its stock will run out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// This works fine.
Set vd_stockRemaining = Aggr(
    Sum(TOTAL &amp;lt;SKU&amp;gt; m_stock) -
    Rangesum(Above(Sum(m_orders), 0, RowNo())), 
SKU, ([Order Date], NUMERIC));

// This does not work.  It returns null for every SKU.
Set vd_starvationDate = Aggr(Date(
    FirstSortedValue({&amp;lt;$(vd_stockRemaining)={"&amp;lt;=0"}&amp;gt;}[Order Date], -$(vd_stockRemaining))
), SKU);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using this instead for now:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// This works but seems hacky/overcomplicated.
Set vd_starvationDate = Aggr(If(Sum(m_stock) &amp;gt; Sum(m_orders), Null(), Date(
    FirstSortedValue([Order Date], If(
	     $(vd_stockRemaining) &amp;lt;= 0,
	    -$(vd_stockRemaining), 
	    1000000000000
	)
))), SKU);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 00:25:59 GMT</pubDate>
    <dc:creator>mmarchese</dc:creator>
    <dc:date>2024-11-16T00:25:59Z</dc:date>
    <item>
      <title>Is it possible to test derived fields in set expressions?</title>
      <link>https://community.qlik.com/t5/App-Development/Is-it-possible-to-test-derived-fields-in-set-expressions/m-p/1791540#M61906</link>
      <description>&lt;P&gt;Can I put a dimension derived with Aggr in the left side of a set expression?&amp;nbsp; It's not working for me right now, but I'm not sure why.&lt;/P&gt;&lt;P&gt;For each product, I have the current stock and list of orders (with dates).&amp;nbsp; I'm trying to get the date for each product when its stock will run out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// This works fine.
Set vd_stockRemaining = Aggr(
    Sum(TOTAL &amp;lt;SKU&amp;gt; m_stock) -
    Rangesum(Above(Sum(m_orders), 0, RowNo())), 
SKU, ([Order Date], NUMERIC));

// This does not work.  It returns null for every SKU.
Set vd_starvationDate = Aggr(Date(
    FirstSortedValue({&amp;lt;$(vd_stockRemaining)={"&amp;lt;=0"}&amp;gt;}[Order Date], -$(vd_stockRemaining))
), SKU);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using this instead for now:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// This works but seems hacky/overcomplicated.
Set vd_starvationDate = Aggr(If(Sum(m_stock) &amp;gt; Sum(m_orders), Null(), Date(
    FirstSortedValue([Order Date], If(
	     $(vd_stockRemaining) &amp;lt;= 0,
	    -$(vd_stockRemaining), 
	    1000000000000
	)
))), SKU);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 00:25:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Is-it-possible-to-test-derived-fields-in-set-expressions/m-p/1791540#M61906</guid>
      <dc:creator>mmarchese</dc:creator>
      <dc:date>2024-11-16T00:25:59Z</dc:date>
    </item>
  </channel>
</rss>

