<?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: Count Distinct IF (Conditions based on variables) in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735012#M591937</link>
    <description>&lt;P&gt;If CYTD and MONTH_NO are variables,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;COUNT(DISTINCT(IF($(DIFF_YEAR) = 0 and [YEAR] = $(CYTD) and MONTH=$(MONTH_NO), CODE)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, if you put single quotes around $(CYTD) in the IF statement, you would also put single quotes around [YEAR].&amp;nbsp; I test variables by displaying them in a text box to ensure I know what I'm comparing.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Aug 2020 21:22:47 GMT</pubDate>
    <dc:creator>jwjackso</dc:creator>
    <dc:date>2020-08-11T21:22:47Z</dc:date>
    <item>
      <title>Count Distinct IF (Conditions based on variables)</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1734991#M591936</link>
      <description>&lt;P&gt;I know you've already posted similar cases and gotten answers. Based on them I have been able to solve some issues that I had but still present one.&lt;/P&gt;&lt;P&gt;I have to count some codes of the current year and in the corresponding month when the difference between two dates is 0.&lt;/P&gt;&lt;P&gt;This is the code that has issues:&lt;/P&gt;&lt;P&gt;COUNT(DISTINCT(IF($(DIFF_YEAR) = 0 AND [YEAR] = {'CYTD'} AND MONTH = $(=MONTH_NO), CODE)))&lt;/P&gt;&lt;P&gt;When I use the following instruction it works:&lt;BR /&gt;COUNT(DISTINCT(IF($(DIFF_YEAR) = 0, CODE)))&lt;/P&gt;&lt;P&gt;But when I add&amp;nbsp;AND [YEAR] = {'CYTD'}&amp;nbsp; and MONTH = $(=MONTH_NO). Does not show results.&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 18:14:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1734991#M591936</guid>
      <dc:creator>kaisdeco</dc:creator>
      <dc:date>2024-11-16T18:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct IF (Conditions based on variables)</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735012#M591937</link>
      <description>&lt;P&gt;If CYTD and MONTH_NO are variables,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;COUNT(DISTINCT(IF($(DIFF_YEAR) = 0 and [YEAR] = $(CYTD) and MONTH=$(MONTH_NO), CODE)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, if you put single quotes around $(CYTD) in the IF statement, you would also put single quotes around [YEAR].&amp;nbsp; I test variables by displaying them in a text box to ensure I know what I'm comparing.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 21:22:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735012#M591937</guid>
      <dc:creator>jwjackso</dc:creator>
      <dc:date>2020-08-11T21:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct IF (Conditions based on variables)</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735013#M591938</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm working in this issue, and the sentence is working but, only with two conditions:&lt;/P&gt;&lt;P&gt;COUNT(DISTINCT(IF($(DIFF_YEAR) = 0 AND YEAR = 'CYTD', INFORCE_POL_NO))))&lt;/P&gt;&lt;P&gt;When I added this condition: AND MONTH = $(=MONTH_NO). It didn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 21:23:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735013#M591938</guid>
      <dc:creator>kaisdeco</dc:creator>
      <dc:date>2020-08-11T21:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct IF (Conditions based on variables)</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735015#M591939</link>
      <description>&lt;P&gt;try below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;COUNT(DISTINCT(IF($(DIFF_YEAR) = 0 AND [YEAR] = '&lt;STRONG&gt;CYTD'&lt;/STRONG&gt; AND MONTH = &lt;STRONG&gt;$(MONTH_NO)&lt;/STRONG&gt;, CODE)))&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 21:29:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735015#M591939</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-08-11T21:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct IF (Conditions based on variables)</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735055#M591940</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried that but, when I used&amp;nbsp;MONTH = $(MONTH_NO) the sentence does not recognize it. When I use&amp;nbsp;MONTH = $(=MONTH_NO) the sentence recognize the month.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kaisdeco_0-1597197462132.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/38864i797C104230707E44/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kaisdeco_0-1597197462132.png" alt="kaisdeco_0-1597197462132.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 01:59:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735055#M591940</guid>
      <dc:creator>kaisdeco</dc:creator>
      <dc:date>2020-08-12T01:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct IF (Conditions based on variables)</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735276#M591942</link>
      <description>&lt;P&gt;MONTH_NO is field? What values MONTH &amp;amp; MONTH_NO have?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 14:02:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735276#M591942</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-08-12T14:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct IF (Conditions based on variables)</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735308#M591944</link>
      <description>&lt;P&gt;Hi Kush,&lt;/P&gt;&lt;P&gt;MONTH is a field and MONTH_NO is a variable containing the last month of a report I have uploaded. e.g It is currently 6 because I was working with the June data.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 14:56:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735308#M591944</guid>
      <dc:creator>kaisdeco</dc:creator>
      <dc:date>2020-08-12T14:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct IF (Conditions based on variables)</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735310#M591946</link>
      <description>&lt;P&gt;I can see that variable is having blank value. Can you check the variable value in KPI object? What is expression used in that variable?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 14:59:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735310#M591946</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-08-12T14:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct IF (Conditions based on variables)</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735322#M591948</link>
      <description>&lt;P&gt;Hi Kush,&lt;/P&gt;&lt;P&gt;When I used MONTH = $(MONTH_NO) I didn't get the variable value, the value is in blank; however, when I use MONTH = $(&lt;FONT color="#FF0000"&gt;=&lt;/FONT&gt;MONTH) I get the value. In the following example you can check it&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kaisdeco_0-1597245107535.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/38921i8BA7393E7E9EAB62/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kaisdeco_0-1597245107535.png" alt="kaisdeco_0-1597245107535.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now, my issue is because when I use two conditions (DIFF_YEAR &amp;amp; YEAR) I have results but, when I use MONTH as well I did't get it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 15:16:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735322#M591948</guid>
      <dc:creator>kaisdeco</dc:creator>
      <dc:date>2020-08-12T15:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct IF (Conditions based on variables)</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735337#M591950</link>
      <description>&lt;P&gt;Check if your month field has a number value? try&amp;nbsp; with quotes '&lt;SPAN&gt;$(&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;=&lt;/FONT&gt;&lt;SPAN&gt;MONTH_NO)&amp;nbsp;' or '$(MONTH_NO)&amp;nbsp;'&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 15:31:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735337#M591950</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-08-12T15:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct IF (Conditions based on variables)</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735728#M591952</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help. I'd like to share with you that I got the info that I needed so far.&lt;/P&gt;&lt;P&gt;I used this sentence and it's working:&lt;/P&gt;&lt;P&gt;COUNT( DISTINCT( IF( $(DIFF_YEAR) = 0 AND YEAR = 'CYTD' AND&lt;FONT color="#FF0000"&gt; MTH_NO&lt;/FONT&gt; = $(=MONTH_NO), INFORCE_POL_NO)))&lt;/P&gt;&lt;P&gt;I was checking the month values when you (Kush) asked me and I found that I was taking a bad field MONTH and I have to take&amp;nbsp; MTH_NO.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2020 17:48:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-IF-Conditions-based-on-variables/m-p/1735728#M591952</guid>
      <dc:creator>kaisdeco</dc:creator>
      <dc:date>2020-08-13T17:48:17Z</dc:date>
    </item>
  </channel>
</rss>

