<?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: Set analysis: Making a week measure responsive to a date filter. in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Set-analysis-Making-a-week-measure-responsive-to-a-date-filter/m-p/2156537#M93673</link>
    <description>&lt;P&gt;Hello! Thanks for your reply!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, I tried it and it still shows me the calculation for the selected Date, instead of the Week Year, when a Date selection has been made.&lt;/P&gt;
&lt;P&gt;If it helps, this is the resulting full code:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;if(
    IsNull(GetFieldSelections(Fecha)),
    [Rango Cirugías Semanal],
    max(aggr(count(distinct {&amp;lt; [Fecha]=, ['Semana Año']={'$(= [Semana Año])'}&amp;gt;} [ID CirugiaQ]), Fecha))&amp;amp;'-'&amp;amp;
min(aggr(count({&amp;lt;[Fecha]=,['Semana Año']={'$(= [Semana Año])'}, [ID CirugiaQ] -= {"=count(distinct [ID CirugiaQ])=0"}&amp;gt;} distinct [ID CirugiaQ]), Fecha))
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Dec 2023 02:23:18 GMT</pubDate>
    <dc:creator>jyanik</dc:creator>
    <dc:date>2023-12-28T02:23:18Z</dc:date>
    <item>
      <title>Set analysis: Making a week measure responsive to a date filter.</title>
      <link>https://community.qlik.com/t5/App-Development/Set-analysis-Making-a-week-measure-responsive-to-a-date-filter/m-p/2156207#M93646</link>
      <description>&lt;P&gt;Hello!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to create an expression that calculates the weekly range of&amp;nbsp;surgeries taking place in a hospital, expressed as the minimum amount of surgeries in a day of that week, a '-' and the maximum amount of surgeries in a day of that week.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The request is to put that expression on a KPI that shows the range for the max week by default, or the range of the corresponding week when a Selection has been made on the field 'Fecha' A date field on the format 'DD/MM/YYYY'&lt;/P&gt;
&lt;P&gt;I wrote an expression that gives me the desired output when no selections have been made, but when I make a selection of the field Fecha (Date), it gives me the amount of surgeries on that day, twice, instead of the min and max surgeries of that week.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anybody know how to make it so that the selection of the field Fecha brings me the output for its corresponding week, instead of that day?&lt;/P&gt;
&lt;P&gt;Adding another field for filter is not an option as the request was that the Date field was the only filter on the App&lt;/P&gt;
&lt;P&gt;My code so far is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="css"&gt;max(aggr(count(distinct {&amp;lt;['Semana Año']={'$(= [Semana Año])'}&amp;gt;} [ID CirugiaQ]), Fecha))&amp;amp;'-'&amp;amp;
min(aggr(count({&amp;lt;['Semana Año']={'$(= [Semana Año])'}, [ID CirugiaQ] -= {"=count(distinct [ID CirugiaQ])=0"}&amp;gt;} distinct [ID CirugiaQ]), Fecha))
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2023 14:17:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-analysis-Making-a-week-measure-responsive-to-a-date-filter/m-p/2156207#M93646</guid>
      <dc:creator>jyanik</dc:creator>
      <dc:date>2023-12-26T14:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis: Making a week measure responsive to a date filter.</title>
      <link>https://community.qlik.com/t5/App-Development/Set-analysis-Making-a-week-measure-responsive-to-a-date-filter/m-p/2156432#M93658</link>
      <description>&lt;P&gt;you have to add : DateFiel = , in you expression&lt;BR /&gt;&lt;BR /&gt;i.E&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;max(aggr(count(distinct {&amp;lt;&amp;nbsp;&lt;STRONG&gt;[Date]=,&lt;/STRONG&gt;&amp;nbsp;['Semana Año']={'$(= [Semana Año])'}&amp;gt;} [ID CirugiaQ]), Fecha))&amp;amp;'-'&amp;amp;&lt;BR /&gt;min(aggr(count({&amp;lt;&lt;STRONG&gt;[Date]=,&lt;/STRONG&gt;['Semana Año']={'$(= [Semana Año])'}, [ID CirugiaQ] -= {"=count(distinct [ID CirugiaQ])=0"}&amp;gt;} distinct [ID CirugiaQ]), Fecha))&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 14:25:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-analysis-Making-a-week-measure-responsive-to-a-date-filter/m-p/2156432#M93658</guid>
      <dc:creator>TcnCunha_M</dc:creator>
      <dc:date>2023-12-27T14:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis: Making a week measure responsive to a date filter.</title>
      <link>https://community.qlik.com/t5/App-Development/Set-analysis-Making-a-week-measure-responsive-to-a-date-filter/m-p/2156537#M93673</link>
      <description>&lt;P&gt;Hello! Thanks for your reply!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, I tried it and it still shows me the calculation for the selected Date, instead of the Week Year, when a Date selection has been made.&lt;/P&gt;
&lt;P&gt;If it helps, this is the resulting full code:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;if(
    IsNull(GetFieldSelections(Fecha)),
    [Rango Cirugías Semanal],
    max(aggr(count(distinct {&amp;lt; [Fecha]=, ['Semana Año']={'$(= [Semana Año])'}&amp;gt;} [ID CirugiaQ]), Fecha))&amp;amp;'-'&amp;amp;
min(aggr(count({&amp;lt;[Fecha]=,['Semana Año']={'$(= [Semana Año])'}, [ID CirugiaQ] -= {"=count(distinct [ID CirugiaQ])=0"}&amp;gt;} distinct [ID CirugiaQ]), Fecha))
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 02:23:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-analysis-Making-a-week-measure-responsive-to-a-date-filter/m-p/2156537#M93673</guid>
      <dc:creator>jyanik</dc:creator>
      <dc:date>2023-12-28T02:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis: Making a week measure responsive to a date filter.</title>
      <link>https://community.qlik.com/t5/App-Development/Set-analysis-Making-a-week-measure-responsive-to-a-date-filter/m-p/2157518#M93784</link>
      <description>&lt;P&gt;Each single part within your expression may need some set analysis to react appropriate to the selections respectively to ignore them. This means the inner- and outer aggregation as well as aggr() itself and also all nested calculations in the set analysis.&lt;/P&gt;
&lt;P&gt;Further your attempt to exclude ZERO results may not always be working. Beside this it's writing an if-loop within a set analysis - so it might be more helpful to outsource this check as a boolean check against the other result.&lt;/P&gt;
&lt;P&gt;Beside this you may simplify some things by querying the week directly, maybe with something:&lt;/P&gt;
&lt;P&gt;... Week = p(Week) ...&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 15:09:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-analysis-Making-a-week-measure-responsive-to-a-date-filter/m-p/2157518#M93784</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2024-01-02T15:09:19Z</dc:date>
    </item>
  </channel>
</rss>

