<?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: Aggr, count, distinct in set expression for service level calculation in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Aggr-count-distinct-in-set-expression-for-service-level/m-p/1833422#M68803</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I think you could create a dimension to have "on time" vs "not on-time" deliveries, and count the number os orders. You can also make a measure, but check if this would work:&lt;/P&gt;&lt;P&gt;Aggr( nodistinct&lt;/P&gt;&lt;P&gt;if( Count(distinct [On time or not]) = 1 , 'On time', 'Not on time' ),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Order number], [Order line number], [Date to be delivered], [Delivered on] )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then, count the distinct number of orders.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Sep 2021 23:27:06 GMT</pubDate>
    <dc:creator>Gui_Approbato</dc:creator>
    <dc:date>2021-09-02T23:27:06Z</dc:date>
    <item>
      <title>Aggr, count, distinct in set expression for service level calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Aggr-count-distinct-in-set-expression-for-service-level/m-p/1833406#M68801</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I'm trying to calculate a supply chain service level and display it in a table + bar chart.&lt;/P&gt;&lt;P&gt;Each order is split and x lines and the order is considered as delivered on time if &lt;STRONG&gt;all lines have been delivered on time.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="patricesalem_0-1630617326870.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/61255iE5D4998E547399D3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="patricesalem_0-1630617326870.png" alt="patricesalem_0-1630617326870.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For the above order, it has not been delivered on time as one line was shipped late.&lt;/P&gt;&lt;P&gt;I&amp;nbsp; put together a summary table to diplay orders that have delivered on time or not.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="patricesalem_1-1630617660147.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/61256i0D983AA82FD7B7B7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="patricesalem_1-1630617660147.png" alt="patricesalem_1-1630617660147.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then, I have tried to use the same expression to display the service level per week in a bar chart&lt;/P&gt;&lt;P&gt;Unfortunatelly, the expression I use in the table does not work for the chart. So, I've tried to use different aggr, count and distinct functions&lt;/P&gt;&lt;P&gt;The following expression lead me to the best result but it does not work for all orders :&lt;/P&gt;&lt;P&gt;Count(DISTINCT {&amp;lt;[COMMANDE] = {"=Count({&amp;lt;[SM_REELLE_shipped_auto] = {""&amp;lt;=$(=date(max((DATE_REF_TAUX_SERVICE))))""}&amp;gt;}[POSTE]) = Count([POSTE])"}&amp;gt;} [COMMANDE])&lt;/P&gt;&lt;P&gt;ie, for the following order (and also for the first table at the top of the post), it is considered as beeing fully delivered on time :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="patricesalem_0-1630618614912.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/61257iEF1DEC419B5126ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="patricesalem_0-1630618614912.png" alt="patricesalem_0-1630618614912.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess the issue comes from the&amp;nbsp;date(max((DATE_REF_TAUX_SERVICE))))&amp;nbsp; - if I remove the max then no DATE_REF_TAUX_DE_SERVICE is returned resulting in a 0 result for all orders.&lt;/P&gt;&lt;P&gt;Any idea ?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Pat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 21:37:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Aggr-count-distinct-in-set-expression-for-service-level/m-p/1833406#M68801</guid>
      <dc:creator>patricesalem</dc:creator>
      <dc:date>2021-09-02T21:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr, count, distinct in set expression for service level calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Aggr-count-distinct-in-set-expression-for-service-level/m-p/1833422#M68803</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I think you could create a dimension to have "on time" vs "not on-time" deliveries, and count the number os orders. You can also make a measure, but check if this would work:&lt;/P&gt;&lt;P&gt;Aggr( nodistinct&lt;/P&gt;&lt;P&gt;if( Count(distinct [On time or not]) = 1 , 'On time', 'Not on time' ),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [Order number], [Order line number], [Date to be delivered], [Delivered on] )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then, count the distinct number of orders.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 23:27:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Aggr-count-distinct-in-set-expression-for-service-level/m-p/1833422#M68803</guid>
      <dc:creator>Gui_Approbato</dc:creator>
      <dc:date>2021-09-02T23:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr, count, distinct in set expression for service level calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Aggr-count-distinct-in-set-expression-for-service-level/m-p/1833805#M68838</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;thanks for your tips.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Initially, I didn't want to create a "on time"&amp;nbsp; dimension but at the end of the day, no choice and the result is good !&lt;/P&gt;&lt;P&gt;I have adapted your formula to get it working with all examples I found in my db :&lt;/P&gt;&lt;P&gt;=if (&lt;BR /&gt;sum(Aggr( sum(distinct [POSTE_ON_TIME_ZSQ]),[COMMANDE],[POSTE], [YEAR_WEEK_REF_TAUX_SERVICE]))&lt;BR /&gt;=&lt;BR /&gt;aggr(count(distinct [POSTE]),[COMMANDE],[YEAR_WEEK_REF_TAUX_SERVICE])&lt;BR /&gt;,&lt;BR /&gt;1,&lt;BR /&gt;0)&lt;/P&gt;&lt;P&gt;big THANKS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Sep 2021 21:37:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Aggr-count-distinct-in-set-expression-for-service-level/m-p/1833805#M68838</guid>
      <dc:creator>patricesalem</dc:creator>
      <dc:date>2021-09-04T21:37:28Z</dc:date>
    </item>
  </channel>
</rss>

