<?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: Using filters while using a TOTAL statement in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739997#M590611</link>
    <description>&lt;P&gt;Thanks, Sunny. Just out of curiosity. Will the same formula work if I need to do a date based filter? Something like today() - 1 or today() - 7?&lt;/P&gt;</description>
    <pubDate>Mon, 31 Aug 2020 15:55:32 GMT</pubDate>
    <dc:creator>shivram_l</dc:creator>
    <dc:date>2020-08-31T15:55:32Z</dc:date>
    <item>
      <title>Using filters while using a TOTAL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739861#M590605</link>
      <description>&lt;P&gt;There's a table that is created that has 5 columns:&lt;/P&gt;&lt;P&gt;Date | Category | Merchant | Type | Tickets | Transactions&lt;/P&gt;&lt;P&gt;In the above table, Tickets is unique for a combination of Date-Category-Merchant-Type while Transaction is unique for a combination of Date-Category-Merchant (Meaning there will be duplicate values)&lt;/P&gt;&lt;P&gt;One of the metric we need is Ticket/Transactions. In this case, ticket is additive so we just do a sum. For transactions, I use the below statement:&lt;/P&gt;&lt;P&gt;sum(total &amp;lt;date, merchant&amp;gt; if(category = 'category1', aggr(max(transactions), cs_date, merchant)))&lt;/P&gt;&lt;P&gt;The above statement helps in getting the distinct transactions for a date-merchant combination which is then summed to get total transactions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above example is working in terms of the intended effect, but we came across a certain edge case where the logic is failing.&lt;/P&gt;&lt;TABLE width="402"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="64"&gt;Date&lt;/TD&gt;&lt;TD width="64"&gt;Category&lt;/TD&gt;&lt;TD width="66"&gt;Merchant&lt;/TD&gt;&lt;TD width="66"&gt;Type&lt;/TD&gt;&lt;TD width="78"&gt;Transaction&lt;/TD&gt;&lt;TD width="64"&gt;Ticket&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01-Jan&lt;/TD&gt;&lt;TD&gt;C1&lt;/TD&gt;&lt;TD&gt;M1&lt;/TD&gt;&lt;TD&gt;T1&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01-Jan&lt;/TD&gt;&lt;TD&gt;C1&lt;/TD&gt;&lt;TD&gt;M1&lt;/TD&gt;&lt;TD&gt;T2&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01-Jan&lt;/TD&gt;&lt;TD&gt;C1&lt;/TD&gt;&lt;TD&gt;M2&lt;/TD&gt;&lt;TD&gt;T3&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01-Jan&lt;/TD&gt;&lt;TD&gt;C2&lt;/TD&gt;&lt;TD&gt;M1&lt;/TD&gt;&lt;TD&gt;T4&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01-Jan&lt;/TD&gt;&lt;TD&gt;C2&lt;/TD&gt;&lt;TD&gt;M4&lt;/TD&gt;&lt;TD&gt;T5&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the above example, ideally for C1 - M1, the number of transaction based on the above TOTAL statement should be 100 and for C2 - M1 it should be 400&lt;/P&gt;&lt;P&gt;But I'm getting the total for C1 - M1 to be 400 and C2 - M1 to also be 400.&lt;/P&gt;&lt;P&gt;Beginner to Set and Total statements - so any help is appreciated. Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 00:02:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739861#M590605</guid>
      <dc:creator>shivram_l</dc:creator>
      <dc:date>2024-11-16T00:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using filters while using a TOTAL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739899#M590606</link>
      <description>&lt;P&gt;Have you just tried this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sum(Aggr(Max(transactions), cs_date, merchant))&lt;/LI-CODE&gt;&lt;P&gt;Why do you need the if statement? I am guessing category1 = C1 and category2 = C2.... If that is true and you want to see a number for C2-M1 combination, why would you need an if statement? Also, guessing cs_date = Date?&lt;/P&gt;&lt;P&gt;I am not sure if the above expression serves the purpose or not, but it would be easier if you can provide a better example where sample data and the field names in your expression match because right now we have some guess work to do.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 12:53:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739899#M590606</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2020-08-31T12:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using filters while using a TOTAL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739909#M590608</link>
      <description>&lt;P&gt;Yeah. I can understand why the confusion might be there. Pasting the right table and query below for reference:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE width="333"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="46"&gt;date&l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PAN&gt;sum(total &amp;lt;date, merchant&amp;gt; if(category = 'C1', aggr(max(transaction), date, merchant)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So let me try and explain why I need to have an if condition. In my dashboard, I need to have one view for each separate category. Tab-1 will be called C1 where the above statement and other such expressions will have to be only for "C1". Similar for C2, C3, and so on...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46628"&gt;@sunny_talwar&lt;/a&gt;&amp;nbsp;- I tried running the query that you shared. Facing the same problem where for C1-M1 combination I get 400, instead of 100.&lt;/P&gt;&lt;P&gt;This is the expression that I used&lt;/P&gt;&lt;P&gt;sum(if(category = 'C1' , Aggr(Max(transaction), date, merchant)))&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 13:11:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739909#M590608</guid>
      <dc:creator>shivram_l</dc:creator>
      <dc:date>2020-08-31T13:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using filters while using a TOTAL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739926#M590610</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sum(Aggr(
  Max({&amp;lt;category = {'C1'}&amp;gt;} transactions)
, cs_date, merchant))&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 31 Aug 2020 13:31:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739926#M590610</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2020-08-31T13:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using filters while using a TOTAL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739997#M590611</link>
      <description>&lt;P&gt;Thanks, Sunny. Just out of curiosity. Will the same formula work if I need to do a date based filter? Something like today() - 1 or today() - 7?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 15:55:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739997#M590611</guid>
      <dc:creator>shivram_l</dc:creator>
      <dc:date>2020-08-31T15:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using filters while using a TOTAL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739998#M590612</link>
      <description>&lt;P&gt;It should, just make sure to use correct date format when comparing date to Today() - 1 or Today()-7 using the Date function&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 15:58:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1739998#M590612</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2020-08-31T15:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using filters while using a TOTAL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1740201#M590613</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46628"&gt;@sunny_talwar&lt;/a&gt;&amp;nbsp;&amp;nbsp;- So I am trying to use the base solution that you'd suggested above and was trying to expand that further to the need that I have in the dashboard.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, here are some of the nuances:&lt;/P&gt;&lt;P&gt;- The variables that I'm trying to group by in the aggr() function is dependent on the category. So for category = 'C1', might have to aggr based on date and merchant, but for category = 'C2', might have to aggr based only on date.&lt;BR /&gt;In this case, a nested If might work is what I'm thinking&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- There's also a date filter I need to apply. Can't use this in the dimension since for the same metric I need to take yesterday's value and benchmark against the last 2 weeks' value. I tried the below expression but it doesn't seem to be right.&lt;/P&gt;&lt;P&gt;Sum(Aggr(&lt;BR /&gt;Max({&amp;lt;category = {'C1'} and date = {today() - 2} &amp;gt;} transactions)&lt;BR /&gt;, cs_date, merchant))&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 12:21:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-filters-while-using-a-TOTAL-statement/m-p/1740201#M590613</guid>
      <dc:creator>shivram_l</dc:creator>
      <dc:date>2020-09-01T12:21:25Z</dc:date>
    </item>
  </channel>
</rss>

