<?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, in stead of If statement in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233770#M85298</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="jive_text_macro jive_macro_quote" jivemacro="quote"&gt;&lt;BR /&gt;Rob Wunderlich wrote: You can simplfy the island approach by moving the IF into a hidden dimension like:&lt;BR /&gt;=if(CustomerId = cid, cid)&lt;BR /&gt;Then your expression columns do not not require the IF and may be written simply like:&lt;BR /&gt;=sum(amount)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I hadn't even thought to simplify like that. Good idea.&lt;/P&gt;&lt;P&gt;But it made me curious - what is the relative performance of doing the IF in the dimension vs. doing it in the expression? I honestly didn't expect a difference of significance with one dimension and one expression, figuring that QlikView would have to do the same work regardless. So these results (50000 rows, 1000 distinct values on the matching columns) surprised me:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;v8.5 v9.0 SR2&lt;BR /&gt;if() in dimension 30547 ms 27719 ms&lt;BR /&gt;if() in expression 3407 ms 3375 ms&lt;/P&gt;&lt;P&gt;Using an if() in the expression seems SIGNIFICANTLY faster than doing the exact same thing in the dimension. I'm not sure why that would be. I would have THOUGHT that with one dimension and one column, the performance would be the same. Then I would expect that each additional expression would be "free" with the dimension approach, but not with the expression approach. Testing that part...&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;v8.5 v9.0 SR2 3 expressions v8.5&lt;BR /&gt;if() in dimension 30547 ms 27719 ms 30641 ms&lt;BR /&gt;if() in expression 3407 ms 3375 ms 3406 ms&lt;/P&gt;&lt;P&gt;... it turns out that I'm completely wrong again. Apparently, either way, almost all of the time is wrapped up in matching up my fields, and almost no time is actually spent doing the calculations. That makes me think that QlikView is clever enough to realize that the conditions in my expressions are the same, and only do the looping match one time instead of three times. I could be off base, though.&lt;/P&gt;&lt;P&gt;In any case, while I might start with the dimension approach, I'd suggest being willing to switch to the more complicated expression approach if performance seems to be a problem. And even with the expression approach, doing an if() like this is simply going to be slow, even on some fairly small data sets. It makes sense to me here, though. In a sense, this was processing 50000 rows * 1000 distinct values for 50,000,000 combinations to plow through.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Feb 2010 01:01:55 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2010-02-09T01:01:55Z</dc:date>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233763#M85291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please look at attached application. There's two tables loaded with no common field name, but I want the fields "CustomerId" and "cid" to be associated by a set analysis statement.&lt;/P&gt;&lt;P&gt;In the attached application, I have made a table chart with an expression with an If statement, and I want to make an expression with a set statement that calculates the same numbers in that table chart.&lt;/P&gt;&lt;P&gt;How do I write that set statement? Is it possible?&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;Björn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2010 15:37:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233763#M85291</guid>
      <dc:creator />
      <dc:date>2010-02-08T15:37:03Z</dc:date>
    </item>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233764#M85292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I guess that if you use customer in set statement than you can't use customer in dimension. Because when you use set analysis the same expression is applied to all rows.&lt;/P&gt;&lt;P&gt;The second table is made with set statement. So you see Eddie Van Halen has the sum of all four customers, Robert Palmer also has the same sum and so on.&lt;/P&gt;&lt;P&gt;&lt;A href="http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/11/0841.untitled.bmp"&gt;&lt;IMG alt="" border="0" height="212" src="http://community.qlik.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Discussions.Components.Files/11/0841.untitled.bmp" width="328" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Milda&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2010 16:30:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233764#M85292</guid>
      <dc:creator />
      <dc:date>2010-02-08T16:30:20Z</dc:date>
    </item>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233765#M85293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can rename cid as CustomerId. Then the tables will link. Then you only need to sum(amount) in your table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2010 16:34:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233765#M85293</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-02-08T16:34:59Z</dc:date>
    </item>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233766#M85294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you jsomsen, but I don't want to do that. I want to make a set statement that calculates the if statement in my example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2010 16:38:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233766#M85294</guid>
      <dc:creator />
      <dc:date>2010-02-08T16:38:33Z</dc:date>
    </item>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233767#M85295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Milda, but that doesn't help me. I need an expression with a set statement that does "the same" as the If-statement-expression in my example. If it's possible...&lt;BR /&gt;Björn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2010 16:42:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233767#M85295</guid>
      <dc:creator />
      <dc:date>2010-02-08T16:42:54Z</dc:date>
    </item>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233768#M85296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Björn,&lt;/P&gt;&lt;P&gt;Set Analysis allows you to indicate one field with values of other field. This is very slow though and performance is severely affected on more than certain number of records. Anyway, it looks like&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;Sum({&amp;lt; Field1 = Field2 &amp;gt;} Value)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;. Depending on the amount of records involved, I'd keep using IF. Hope this helps. &lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2010 16:55:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233768#M85296</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2010-02-08T16:55:50Z</dc:date>
    </item>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233769#M85297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bjorn,&lt;/P&gt;&lt;P&gt;I don't think it's possible using Set syntax. As John reminded me the other day,&lt;BR /&gt;&lt;A href="http://community.qlik.com/forums/t/25409.aspx"&gt;http://community.qlik.com/forums/t/25409.aspx&lt;/A&gt;&lt;BR /&gt;a set is analyzed once for the entire chart, not for each row.&lt;/P&gt;&lt;P&gt;You can simplfy the island approach by moving the IF into a hidden dimension like:&lt;BR /&gt;=if(CustomerId = cid, cid)&lt;/P&gt;&lt;P&gt;Then your expression columns do not not require the IF and may be written simply like:&lt;BR /&gt;=sum(amount)&lt;/P&gt;&lt;P&gt;See attached example.&lt;/P&gt;&lt;P&gt;-Rob&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2010 23:16:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233769#M85297</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2010-02-08T23:16:59Z</dc:date>
    </item>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233770#M85298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="jive_text_macro jive_macro_quote" jivemacro="quote"&gt;&lt;BR /&gt;Rob Wunderlich wrote: You can simplfy the island approach by moving the IF into a hidden dimension like:&lt;BR /&gt;=if(CustomerId = cid, cid)&lt;BR /&gt;Then your expression columns do not not require the IF and may be written simply like:&lt;BR /&gt;=sum(amount)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I hadn't even thought to simplify like that. Good idea.&lt;/P&gt;&lt;P&gt;But it made me curious - what is the relative performance of doing the IF in the dimension vs. doing it in the expression? I honestly didn't expect a difference of significance with one dimension and one expression, figuring that QlikView would have to do the same work regardless. So these results (50000 rows, 1000 distinct values on the matching columns) surprised me:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;v8.5 v9.0 SR2&lt;BR /&gt;if() in dimension 30547 ms 27719 ms&lt;BR /&gt;if() in expression 3407 ms 3375 ms&lt;/P&gt;&lt;P&gt;Using an if() in the expression seems SIGNIFICANTLY faster than doing the exact same thing in the dimension. I'm not sure why that would be. I would have THOUGHT that with one dimension and one column, the performance would be the same. Then I would expect that each additional expression would be "free" with the dimension approach, but not with the expression approach. Testing that part...&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;v8.5 v9.0 SR2 3 expressions v8.5&lt;BR /&gt;if() in dimension 30547 ms 27719 ms 30641 ms&lt;BR /&gt;if() in expression 3407 ms 3375 ms 3406 ms&lt;/P&gt;&lt;P&gt;... it turns out that I'm completely wrong again. Apparently, either way, almost all of the time is wrapped up in matching up my fields, and almost no time is actually spent doing the calculations. That makes me think that QlikView is clever enough to realize that the conditions in my expressions are the same, and only do the looping match one time instead of three times. I could be off base, though.&lt;/P&gt;&lt;P&gt;In any case, while I might start with the dimension approach, I'd suggest being willing to switch to the more complicated expression approach if performance seems to be a problem. And even with the expression approach, doing an if() like this is simply going to be slow, even on some fairly small data sets. It makes sense to me here, though. In a sense, this was processing 50000 rows * 1000 distinct values for 50,000,000 combinations to plow through.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Feb 2010 01:01:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233770#M85298</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-02-09T01:01:55Z</dc:date>
    </item>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233771#M85299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all. I am not sure why this has been bothering me, but I am trying to see if I am missing something. Why would you not want to associate CustomerId and Cid in your script so that these tables were then linked? Then all you would need is a simple sum() in the chart. It seems that placing that If ( ) statement would just add unneeded overhead to the analytic.&lt;/P&gt;&lt;P&gt;This curious mind thanks you in advance,&lt;/P&gt;&lt;P&gt;JS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Feb 2010 21:06:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233771#M85299</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-02-09T21:06:00Z</dc:date>
    </item>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233772#M85300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thanks for your answer. It's due to work with an app with several tables with huge amounts of records. I'm trying out how to relate the tables in the QV layout without actually relating them in the load script. Just to see if it's possible. Else I have to come up with a DW solution before I load anything into QV.&lt;BR /&gt;The performance of the QV app is bad when having these huge tables related, and the load gets really heavy when I use mappings and joins to reduce the amount of tables, even when I do the most of the data preparement in SQL script.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Björn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 12:38:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233772#M85300</guid>
      <dc:creator />
      <dc:date>2010-02-10T12:38:32Z</dc:date>
    </item>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233773#M85301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John, Rob &amp;amp; everybody else,&lt;BR /&gt;thank you very much for your inputs.&lt;/P&gt;&lt;P&gt;I think I now know the answer to my question, that set can't replace if statements, not in this way anyhow.&lt;/P&gt;&lt;P&gt;Again, thank you all. I will now use this forum more in my future work with QlikView.&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Björn.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 12:44:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233773#M85301</guid>
      <dc:creator />
      <dc:date>2010-02-10T12:44:04Z</dc:date>
    </item>
    <item>
      <title>Set analysis, in stead of If statement</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233774#M85302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, the performance is likely to be much worse relating fields in your charts with if() than simply relating them in your data model. I think your answer is what you already stated, "Else I have to come up with a DW solution before I load anything into QlikView". Mind you, you don't need a full data warehouse before you can start on a QlikView application. But I do think you want to solve this problem in your data model, not in your chart.&lt;/P&gt;&lt;P&gt;I'm not sure if this is applicable, but I'll outline our basic technique in our shop. Our actual data loads from the databases are done in separate QVWs that create QVDs. The user applications simply load from these QVDs. When loading from a QVD, if performance is an issue, you need to make sure you're getting an "optimized load". For an optimized load, your where expression can have no more than a single exists() and no other conditions, and you can't have any expressions in your list of fields (though you can rename them). A typical approach for me might be:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;[My Table]:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;Some Field&lt;BR /&gt;Value 1&lt;BR /&gt;Value 2&lt;BR /&gt;Value 3&lt;BR /&gt;];&lt;BR /&gt;INNER JOIN ([My Table])&lt;BR /&gt;LOAD&lt;BR /&gt; "Key Field"&lt;BR /&gt;,"Some Field"&lt;BR /&gt;,"Some Other Field"&lt;BR /&gt;,"Field 3" as "Cost"&lt;BR /&gt;,"Field 4" as "Weight"&lt;BR /&gt;,"Field 5" as "Revenue"&lt;BR /&gt;FROM My_Table.qvd (QVD)&lt;BR /&gt;WHERE exists("Some Field")&lt;BR /&gt;;&lt;BR /&gt;INNER JOIN ([My Table])&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;Some Other Field&lt;BR /&gt;A&lt;BR /&gt;B&lt;BR /&gt;C&lt;BR /&gt;];&lt;BR /&gt;LEFT JOIN ([My Table])&lt;BR /&gt;LOAD&lt;BR /&gt; "Key Field"&lt;BR /&gt;,if("Weight"&amp;gt;5,'Y','N') as "Heavy?"&lt;BR /&gt;,"Revenue" - "Cost" as "Margin"&lt;BR /&gt;RESIDENT [My Table]&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;It's a lot more trouble than how we might normally write this, but it can be worth it when load performance is a problem. It may also be worth adding common "calculated fields" to the QVD to save the last step. Also, if you need the same data in more than one user application, you don't want to have to maintain these calculations in more than one place.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 18:30:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-in-stead-of-If-statement/m-p/233774#M85302</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-02-10T18:30:06Z</dc:date>
    </item>
  </channel>
</rss>

