<?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 SET ANALYSIS USING VARIABLE AS FIELD IN CONDITION in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563193#M456909</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote the below expression but when using variable as filed in the condition, it does not work.&lt;/P&gt;&lt;P&gt;It seems to be an issue with the syntax of the field (or variable) v(Metric%).&lt;/P&gt;&lt;P&gt;I need it to be a dynamic filed name, as the condition changes with the fields.&lt;/P&gt;&lt;P&gt;Basically i want my expression to divide the count of 'ON TIME' for the selected dynamic field divided by the sum of&amp;nbsp;'ON TIME' and 'LATE'&amp;nbsp;for the selected dynamic field.&lt;/P&gt;&lt;P&gt;So i need both fields in red and green to be dynamic.&lt;/P&gt;&lt;P&gt;The ones in green seem to work fine, but not the ones in red.&lt;/P&gt;&lt;P&gt;Can you help ?&lt;/P&gt;&lt;P&gt;COUNT(DISTINCT{&amp;lt;[MonthID2]={"&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)"},&lt;FONT color="#FF0000"&gt;$(vMetric%)&lt;/FONT&gt; = {'ON TIME'}&amp;gt;}$(&lt;FONT color="#008000"&gt;vMetric%&lt;/FONT&gt;))/&lt;BR /&gt;(COUNT(DISTINCT{&amp;lt;[MonthID2]={"&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)"},&lt;FONT color="#FF0000"&gt;$(vMetric%)&lt;/FONT&gt;={'ON TIME'}&amp;gt;}$(&lt;FONT color="#008000"&gt;vMetric%&lt;/FONT&gt;))+&lt;BR /&gt;COUNT(DISTINCT{&amp;lt;[MonthID2]={"&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)"},&lt;FONT color="#FF0000"&gt;$(vMetric%)&lt;/FONT&gt;={'ON TIME'}&amp;gt;}$(&lt;FONT color="#008000"&gt;vMetric%&lt;/FONT&gt;)))&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 04:00:11 GMT</pubDate>
    <dc:creator>maudifer</dc:creator>
    <dc:date>2024-11-16T04:00:11Z</dc:date>
    <item>
      <title>SET ANALYSIS USING VARIABLE AS FIELD IN CONDITION</title>
      <link>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563193#M456909</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote the below expression but when using variable as filed in the condition, it does not work.&lt;/P&gt;&lt;P&gt;It seems to be an issue with the syntax of the field (or variable) v(Metric%).&lt;/P&gt;&lt;P&gt;I need it to be a dynamic filed name, as the condition changes with the fields.&lt;/P&gt;&lt;P&gt;Basically i want my expression to divide the count of 'ON TIME' for the selected dynamic field divided by the sum of&amp;nbsp;'ON TIME' and 'LATE'&amp;nbsp;for the selected dynamic field.&lt;/P&gt;&lt;P&gt;So i need both fields in red and green to be dynamic.&lt;/P&gt;&lt;P&gt;The ones in green seem to work fine, but not the ones in red.&lt;/P&gt;&lt;P&gt;Can you help ?&lt;/P&gt;&lt;P&gt;COUNT(DISTINCT{&amp;lt;[MonthID2]={"&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)"},&lt;FONT color="#FF0000"&gt;$(vMetric%)&lt;/FONT&gt; = {'ON TIME'}&amp;gt;}$(&lt;FONT color="#008000"&gt;vMetric%&lt;/FONT&gt;))/&lt;BR /&gt;(COUNT(DISTINCT{&amp;lt;[MonthID2]={"&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)"},&lt;FONT color="#FF0000"&gt;$(vMetric%)&lt;/FONT&gt;={'ON TIME'}&amp;gt;}$(&lt;FONT color="#008000"&gt;vMetric%&lt;/FONT&gt;))+&lt;BR /&gt;COUNT(DISTINCT{&amp;lt;[MonthID2]={"&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)"},&lt;FONT color="#FF0000"&gt;$(vMetric%)&lt;/FONT&gt;={'ON TIME'}&amp;gt;}$(&lt;FONT color="#008000"&gt;vMetric%&lt;/FONT&gt;)))&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 04:00:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563193#M456909</guid>
      <dc:creator>maudifer</dc:creator>
      <dc:date>2024-11-16T04:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: SET ANALYSIS USING VARIABLE AS FIELD IN CONDITION</title>
      <link>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563199#M456910</link>
      <description>Hi Maudifer,&lt;BR /&gt;Because I don't have your sample data, but the key to using the variables in set analysis is to keep the data type be same.&lt;BR /&gt;In your case, you need to make sure that the data type of MonthID2 is same with your 2 variables:vPrevMonth5ID, vCurrMonthID.&lt;BR /&gt;If not, you can use function to change your data type of your 2 variables.&lt;BR /&gt;Please try.&lt;BR /&gt;Aiolos Zhao</description>
      <pubDate>Sun, 31 Mar 2019 13:57:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563199#M456910</guid>
      <dc:creator>uacg0009</dc:creator>
      <dc:date>2019-03-31T13:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: SET ANALYSIS USING VARIABLE AS FIELD IN CONDITION</title>
      <link>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563209#M456911</link>
      <description>Maybe it is the whitespace of you field name that is causing you trouble?&lt;BR /&gt;&lt;BR /&gt;Try:&lt;BR /&gt;COUNT(DISTINCT{&amp;lt;[MonthID2]={"&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)"},[$(vMetric%)] = {'ON TIME'}&amp;gt;}[$(vMetric%)])/&lt;BR /&gt;(COUNT(DISTINCT{&amp;lt;[MonthID2]={"&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)"},[$(vMetric%)]={'ON TIME'}&amp;gt;}[$(vMetric%)])+&lt;BR /&gt;COUNT(DISTINCT{&amp;lt;[MonthID2]={"&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)"},[$(vMetric%)]={'ON TIME'}&amp;gt;}[$(vMetric%)]))</description>
      <pubDate>Sun, 31 Mar 2019 15:55:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563209#M456911</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2019-03-31T15:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: SET ANALYSIS USING VARIABLE AS FIELD IN CONDITION</title>
      <link>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563262#M456912</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/4585"&gt;@maudifer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/25001"&gt;@Vegar&lt;/a&gt;&amp;nbsp; pointed out the white space might be causing the issue, if not then you can try something similar to below ans check if it works for you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;='sum({&amp;lt;'&amp;nbsp; &amp;amp;&amp;nbsp; [$(variable)] &amp;amp; '={1,2,3}&amp;gt;} field)'&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 05:21:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563262#M456912</guid>
      <dc:creator>pradosh_thakur</dc:creator>
      <dc:date>2019-04-01T05:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: SET ANALYSIS USING VARIABLE AS FIELD IN CONDITION</title>
      <link>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563315#M456913</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks you all for your suggestions, but unfortunately nothing worked.&lt;/P&gt;&lt;P&gt;I put below the full correct expression I need. With just the normal field, it works fine, but when i switch the normal field&amp;nbsp; with a variable, it does not work.I also attached screen shot of the 2 expressions in set analysis, so you can see what gets line in red there. Basically it seems to not like the value condition. You can see below the definition of the variable too.&lt;/P&gt;&lt;P&gt;All the fields's values are either 'ON TIME' OR 'LATE'.&lt;/P&gt;&lt;P&gt;Any other idea on how to fix it ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expression with normal field:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;COUNT(DISTINCT{&amp;lt;[MonthID2]={'&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)'},[FR VS ATD]={'ON TIME'}&amp;gt;}[Bill of Lading (BOL)])/&lt;BR /&gt;(COUNT(DISTINCT{&amp;lt;[MonthID2]={'&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)'},[FR VS ATD]={'ON TIME'}&amp;gt;}[Bill of Lading (BOL)])+&lt;BR /&gt;COUNT(DISTINCT{&amp;lt;[MonthID2]={'&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)'},[FR VS ATD]={'LATE'}&amp;gt;}[Bill of Lading (BOL)]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expression with Variable field:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;COUNT(DISTINCT{&amp;lt;[MonthID2]={'&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)'},$(vMetric%)={'ON TIME'}&amp;gt;}[Bill of Lading (BOL)])/&lt;BR /&gt;(COUNT(DISTINCT{&amp;lt;[MonthID2]={'&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)'},$(vMetric%)={'ON TIME'}&amp;gt;}[Bill of Lading (BOL)])+&lt;BR /&gt;COUNT(DISTINCT{&amp;lt;[MonthID2]={'&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)'},$(vMetric%)={'LATE'}&amp;gt;}[Bill of Lading (BOL)]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variable ($(vMetric%)) definition:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if(Metric%='FR VS ATD',[FR VS ATD],&lt;BR /&gt;if(Metric%='TT PORT TO PORT', [TT PORT TO PORT],&lt;/P&gt;&lt;P&gt;if(Metric%='ATA TO CC', [ATA TO CC],&lt;/P&gt;&lt;P&gt;if(Metric%='CC TO DL', [CC TO DL],&lt;/P&gt;&lt;P&gt;if(Metric%='TT DOOR TO DOOR', [TT PORT TO PORT],&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if(Metric%='BD TO DL', [BD TO DL]&lt;BR /&gt;))))))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 07:48:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563315#M456913</guid>
      <dc:creator>maudifer</dc:creator>
      <dc:date>2019-04-01T07:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: SET ANALYSIS USING VARIABLE AS FIELD IN CONDITION</title>
      <link>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563354#M456914</link>
      <description>&lt;PRE&gt;COUNT(DISTINCT{&amp;lt;[MonthID2]={'&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)'},$(=vMetric%)={'ON TIME'}&amp;gt;}[Bill of Lading (BOL)])/
(COUNT(DISTINCT{&amp;lt;[MonthID2]={'&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)'},$(=vMetric%)={'ON TIME'}&amp;gt;}[Bill of Lading (BOL)])+
COUNT(DISTINCT{&amp;lt;[MonthID2]={'&amp;gt;=$(vPrevMonth5ID)&amp;lt;=$(vCurrMonthID)'},$(=vMetric%)={'LATE'}&amp;gt;}[Bill of Lading (BOL)]))&lt;/PRE&gt;&lt;P&gt;Try the above . I hpe it works with the variable you have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if that doesn't work then use your expression and change your variable to the below . notice the '='&amp;nbsp; i used in the starting , don't omit that.&lt;/P&gt;&lt;PRE&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/FONT&gt;if(Metric%='FR VS ATD',[FR VS ATD],
if(Metric%='TT PORT TO PORT', [TT PORT TO PORT],

if(Metric%='ATA TO CC', [ATA TO CC],

if(Metric%='CC TO DL', [CC TO DL],

if(Metric%='TT DOOR TO DOOR', [TT PORT TO PORT],


if(Metric%='BD TO DL', [BD TO DL]
))))))&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 09:12:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SET-ANALYSIS-USING-VARIABLE-AS-FIELD-IN-CONDITION/m-p/1563354#M456914</guid>
      <dc:creator>pradosh_thakur</dc:creator>
      <dc:date>2019-04-01T09:12:34Z</dc:date>
    </item>
  </channel>
</rss>

