<?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 adapt Group By from script to measure in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/adapt-Group-By-from-script-to-measure/m-p/2463405#M99034</link>
    <description>&lt;P&gt;Hey ! I have a table like this:&lt;BR /&gt;Ticket Number, Item Number, Task Number, Ticket_Status, Item_Status, Task_Status&lt;BR /&gt;1, 1, 1, Closed, Closed, Closed&lt;BR /&gt;1, 1, 2, Closed, Closed, Closed&lt;BR /&gt;1, 2, 1, Closed, Open, Closed&lt;BR /&gt;2, -, -, Closed, -, -&amp;nbsp;&lt;BR /&gt;3, 1, 1, Closed, Closed, Open&lt;BR /&gt;3, 1, 2, Closed, Closed, Closed&lt;BR /&gt;4, 1, 1,&amp;nbsp; Closed, Closed, Closed&lt;BR /&gt;4, 1, 2,&amp;nbsp; Closed, Closed, Closed&lt;BR /&gt;4, 2, 1,&amp;nbsp; Closed, Closed, Closed&lt;BR /&gt;&lt;BR /&gt;My goal is to detect inconsistencies, where everything isn't closed correctly. In Qlik Script, I've done something like this :&amp;nbsp;&lt;BR /&gt;1) Load my ticket table as normal&lt;BR /&gt;2) Make a table which loads in the resident table Tickets, groups by Ticket_Number, and counts the number of total items, of total tasks, of closed tasks, and of closed items.&lt;BR /&gt;3) Left Join my table tickets with a table with my ticket_number and a mismatch value, calculated with the calculations from (2).&lt;BR /&gt;&lt;BR /&gt;This works, but this slows down a bit the loading of the table, and my superior would rather I do a measure in the sheet directly.&lt;BR /&gt;&lt;BR /&gt;The thing is, I haven't been able to obtain the same results. I'm not able to count all total items and all closed items for a single ticket. Using Total doesn't get everything, and using ALL or {1} makes it so the table cannot be filtered anymore. I've tried many aggregations without success. The results have never been exact anyway.&lt;BR /&gt;&lt;BR /&gt;Here's how I compute each of those variables (with total here, but i tried everything I mentionned,) :&lt;BR /&gt;* Total Item Count :&amp;nbsp;Count(Total Item_Number)&amp;nbsp;&lt;BR /&gt;* Total Task Count :&amp;nbsp;Count(Total Task_Number)&lt;BR /&gt;* Closed Item Count :&amp;nbsp;Sum(Total If(WildMatch(Item_Status, 'Cancel*', 'Close*', 'Resolved'), 1, 0))&lt;BR /&gt;* Closed Task Count :&amp;nbsp;Sum(Total If(WildMatch(Task_Status, 'Cancel*', 'Close*', 'Resolved'), 1, 0))&lt;BR /&gt;&lt;BR /&gt;What am I doing wrong?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2024 11:56:51 GMT</pubDate>
    <dc:creator>Cobran53</dc:creator>
    <dc:date>2024-06-18T11:56:51Z</dc:date>
    <item>
      <title>adapt Group By from script to measure</title>
      <link>https://community.qlik.com/t5/App-Development/adapt-Group-By-from-script-to-measure/m-p/2463405#M99034</link>
      <description>&lt;P&gt;Hey ! I have a table like this:&lt;BR /&gt;Ticket Number, Item Number, Task Number, Ticket_Status, Item_Status, Task_Status&lt;BR /&gt;1, 1, 1, Closed, Closed, Closed&lt;BR /&gt;1, 1, 2, Closed, Closed, Closed&lt;BR /&gt;1, 2, 1, Closed, Open, Closed&lt;BR /&gt;2, -, -, Closed, -, -&amp;nbsp;&lt;BR /&gt;3, 1, 1, Closed, Closed, Open&lt;BR /&gt;3, 1, 2, Closed, Closed, Closed&lt;BR /&gt;4, 1, 1,&amp;nbsp; Closed, Closed, Closed&lt;BR /&gt;4, 1, 2,&amp;nbsp; Closed, Closed, Closed&lt;BR /&gt;4, 2, 1,&amp;nbsp; Closed, Closed, Closed&lt;BR /&gt;&lt;BR /&gt;My goal is to detect inconsistencies, where everything isn't closed correctly. In Qlik Script, I've done something like this :&amp;nbsp;&lt;BR /&gt;1) Load my ticket table as normal&lt;BR /&gt;2) Make a table which loads in the resident table Tickets, groups by Ticket_Number, and counts the number of total items, of total tasks, of closed tasks, and of closed items.&lt;BR /&gt;3) Left Join my table tickets with a table with my ticket_number and a mismatch value, calculated with the calculations from (2).&lt;BR /&gt;&lt;BR /&gt;This works, but this slows down a bit the loading of the table, and my superior would rather I do a measure in the sheet directly.&lt;BR /&gt;&lt;BR /&gt;The thing is, I haven't been able to obtain the same results. I'm not able to count all total items and all closed items for a single ticket. Using Total doesn't get everything, and using ALL or {1} makes it so the table cannot be filtered anymore. I've tried many aggregations without success. The results have never been exact anyway.&lt;BR /&gt;&lt;BR /&gt;Here's how I compute each of those variables (with total here, but i tried everything I mentionned,) :&lt;BR /&gt;* Total Item Count :&amp;nbsp;Count(Total Item_Number)&amp;nbsp;&lt;BR /&gt;* Total Task Count :&amp;nbsp;Count(Total Task_Number)&lt;BR /&gt;* Closed Item Count :&amp;nbsp;Sum(Total If(WildMatch(Item_Status, 'Cancel*', 'Close*', 'Resolved'), 1, 0))&lt;BR /&gt;* Closed Task Count :&amp;nbsp;Sum(Total If(WildMatch(Task_Status, 'Cancel*', 'Close*', 'Resolved'), 1, 0))&lt;BR /&gt;&lt;BR /&gt;What am I doing wrong?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 11:56:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/adapt-Group-By-from-script-to-measure/m-p/2463405#M99034</guid>
      <dc:creator>Cobran53</dc:creator>
      <dc:date>2024-06-18T11:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: adapt Group By from script to measure</title>
      <link>https://community.qlik.com/t5/App-Development/adapt-Group-By-from-script-to-measure/m-p/2463449#M99046</link>
      <description>&lt;P&gt;I assume that many of your UI attempts with aggr() and/or TOTAL and/or {1} didn't address the underlying cause and making therefore all only complicated because NULL isn't stored in any way and couldn't be directly accessed/selected.&lt;/P&gt;
&lt;P&gt;There are indirect ways but I wouldn't recommend them - they should be rather considered as a worst case scenario. Often better is to replace NULL during the load - this might be done with simple measurements like:&lt;/P&gt;
&lt;P&gt;if(isnull(MyField), '&amp;lt;NULL', MyField) as MyField&lt;/P&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if(len(trim(MyField)), MyField, '&amp;lt;NULL') as MyField&lt;/P&gt;
&lt;P&gt;An alternatively to the above functions are coalesce() or alt() or by more fields the use of the various NULL variables.&lt;/P&gt;
&lt;P&gt;Beside of this I would remain to do the essential things within the script - probably by flagging the records and without touching the NULL, maybe with something:&lt;/P&gt;
&lt;P&gt;sign(len(F1)) *&amp;nbsp;sign(len(F2)) *&amp;nbsp;sign(len(F3)) as [0/1 Flag],&lt;BR /&gt;rangesum(sign(len(F1)),&amp;nbsp;sign(len(F2)),&amp;nbsp;sign(len(F3))) as [Quality Flag]&lt;/P&gt;
&lt;P&gt;Such measurements are fast within the load - not like aggregation-loads - and quite simple sum() + count() with/without set analysis and/or as dimensions/selections should enable all needed views.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 13:21:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/adapt-Group-By-from-script-to-measure/m-p/2463449#M99046</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2024-06-18T13:21:40Z</dc:date>
    </item>
  </channel>
</rss>

