<?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: joining with conditions in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434901#M96937</link>
    <description>&lt;P&gt;Hi Jure - thanks for the feedback. I looked at it as a possible way of getting around my issue but I don’t see how I can use the interval match and also include my three joins.&lt;/P&gt;</description>
    <pubDate>Tue, 26 Mar 2024 21:58:34 GMT</pubDate>
    <dc:creator>ismailk94</dc:creator>
    <dc:date>2024-03-26T21:58:34Z</dc:date>
    <item>
      <title>joining with conditions</title>
      <link>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434736#M96920</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;
&lt;P&gt;I'm attempting to translate some SQL syntax into Qlik script but I'm having trouble finding the solution.&lt;/P&gt;
&lt;P&gt;I have two tables - "Fact_Transactions" and "Dim_Membership".&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Fact_Transactions (Table1):&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;"MemberID"&lt;/LI&gt;
&lt;LI&gt;"TransactionID"&lt;/LI&gt;
&lt;LI&gt;"TransactionDate"&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Dim_Membership (Table2):&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;"MemberID"&lt;/LI&gt;
&lt;LI&gt;"Subscription Start Date"&lt;/LI&gt;
&lt;LI&gt;"Subscription End Date"&lt;/LI&gt;
&lt;LI&gt;"ActualEndDate"&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;My objective is to move "ActualEndDate" to the "Fact_Transactions" table under the following conditions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;"MemberID"&lt;STRONG&gt;(Table2)&lt;/STRONG&gt;="MemberID"&lt;STRONG&gt;(Table1)&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;"ActualEndDate"&lt;STRONG&gt;(Table2)&lt;/STRONG&gt;&amp;gt;="TransactionDate"&lt;STRONG&gt;(Table1)&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;"Subscription Start Date"&lt;STRONG&gt;(Table2)&lt;/STRONG&gt; &amp;lt;= "TransactionDate"&lt;STRONG&gt;(Table1)&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;STRONG style="font-family: inherit;"&gt;Any ideas? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 26 Mar 2024 13:32:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434736#M96920</guid>
      <dc:creator>ismailk94</dc:creator>
      <dc:date>2024-03-26T13:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: joining with conditions</title>
      <link>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434787#M96923</link>
      <description>Hey,&lt;BR /&gt;use Intervalmatch function.&lt;BR /&gt;Br</description>
      <pubDate>Tue, 26 Mar 2024 14:42:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434787#M96923</guid>
      <dc:creator>Jure</dc:creator>
      <dc:date>2024-03-26T14:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: joining with conditions</title>
      <link>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434827#M96928</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Certainly! You can achieve this in Qlik script using the JOIN and WHERE clauses. Here's a sample script:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;// Load Fact_Transactions table&lt;BR /&gt;Fact_Transactions:&lt;BR /&gt;LOAD&lt;BR /&gt;MemberID,&lt;BR /&gt;TransactionID,&lt;BR /&gt;TransactionDate&lt;BR /&gt;FROM [Path\to\Fact_Transactions.csv]&lt;BR /&gt;(txt, utf8, delimiter is ',', embedded labels);&lt;/P&gt;
&lt;P&gt;// Load Dim_Membership table&lt;BR /&gt;Dim_Membership:&lt;BR /&gt;LOAD&lt;BR /&gt;MemberID,&lt;BR /&gt;[Subscription Start Date],&lt;BR /&gt;[Subscription End Date],&lt;BR /&gt;ActualEndDate&lt;BR /&gt;FROM [Path\to\Dim_Membership.csv]&lt;BR /&gt;(txt, utf8, delimiter is ',', embedded labels);&lt;/P&gt;
&lt;P&gt;// Join Fact_Transactions with Dim_Membership based on MemberID&lt;BR /&gt;Transactions_With_EndDate:&lt;BR /&gt;LOAD&lt;BR /&gt;Fact_Transactions.*,&lt;BR /&gt;Dim_Membership.ActualEndDate as TransactionEndDate&lt;BR /&gt;RESIDENT Fact_Transactions&lt;BR /&gt;LEFT JOIN&lt;BR /&gt;Dim_Membership&lt;BR /&gt;ON&lt;BR /&gt;Fact_Transactions.MemberID = Dim_Membership.MemberID&lt;BR /&gt;AND&lt;BR /&gt;Dim_Membership.ActualEndDate &amp;gt;= Fact_Transactions.TransactionDate&lt;BR /&gt;AND&lt;BR /&gt;Dim_Membership.[Subscription Start Date] &amp;lt;= Fact_Transactions.TransactionDate;&lt;/P&gt;
&lt;P&gt;// Drop temporary tables and fields&lt;BR /&gt;DROP TABLES Fact_Transactions, Dim_Membership;&lt;BR /&gt;DROP FIELDS MemberID, TransactionDate, [Subscription Start Date];&lt;/P&gt;
&lt;P&gt;// Rename TransactionEndDate field&lt;BR /&gt;Transactions_With_EndDate:&lt;BR /&gt;RENAME FIELD TransactionEndDate TO ActualEndDate;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;This script:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Loads the Fact_Transactions and Dim_Membership tables from their respective CSV files.&lt;/LI&gt;
&lt;LI&gt;Joins the tables based on the MemberID field and the specified conditions using the LEFT JOIN clause.&lt;/LI&gt;
&lt;LI&gt;Renames the TransactionEndDate field to ActualEndDate for clarity.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Make sure to replace "[Path\to\Fact_Transactions.csv]" and "[Path\to\Dim_Membership.csv]" with the actual file paths. Adjust field names and formatting as needed based on your Qlik environment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 16:03:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434827#M96928</guid>
      <dc:creator>BawejaMedia</dc:creator>
      <dc:date>2024-03-26T16:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: joining with conditions</title>
      <link>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434900#M96936</link>
      <description>&lt;P&gt;Hi! Thanks for the feedback.&lt;/P&gt;
&lt;P&gt;I am in QlikCloud.&lt;/P&gt;
&lt;P&gt;the two tables are qvd-files, so I dont see how I can use the syntax you are proposing? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 21:55:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434900#M96936</guid>
      <dc:creator>ismailk94</dc:creator>
      <dc:date>2024-03-26T21:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: joining with conditions</title>
      <link>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434901#M96937</link>
      <description>&lt;P&gt;Hi Jure - thanks for the feedback. I looked at it as a possible way of getting around my issue but I don’t see how I can use the interval match and also include my three joins.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 21:58:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434901#M96937</guid>
      <dc:creator>ismailk94</dc:creator>
      <dc:date>2024-03-26T21:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: joining with conditions</title>
      <link>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434944#M96942</link>
      <description>&lt;P&gt;Definitely use IntervalMatch()&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPrefixes/IntervalMatch.htm" target="_blank" rel="noopener"&gt;https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPrefixes/IntervalMatch.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Its perfect for your setup.&amp;nbsp; It joins a record with a date from one table to record(s) that bear interval(s) in another table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In its most basic form table 1 has a Date and table 2 has start and end date.&amp;nbsp; The intervalmatch does a JOIN of each date in table1 to each matching interval in table2.&lt;/P&gt;
&lt;P&gt;It also works when you need add another field to further restrict the matching of intervals.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 03:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2434944#M96942</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2024-03-27T03:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: joining with conditions</title>
      <link>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2435192#M96950</link>
      <description>&lt;P&gt;The suggested intervalmatch is definitely the right logic to get the wanted associations. But it could be also done with another and simpler approach, like this one (simplified):&lt;/P&gt;
&lt;P&gt;m: mapping load ID &amp;amp; '|' &amp;amp; date(Start + iterno() - 1), F1 &amp;amp; '|' &amp;amp; F2&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;from T2 while&amp;nbsp;Start + iterno() - 1 &amp;lt;= End;&lt;/P&gt;
&lt;P&gt;and in the final load you may use:&lt;/P&gt;
&lt;P&gt;subfield(applymap('m', ID &amp;amp; '|' &amp;amp; Date, 'no match'), '|', 1) as F1&lt;/P&gt;
&lt;P&gt;to get the first field (the subfield-stuff is not mandatory to a mapping but a simple way to return multiple fields like a join would would do without the need to create multiple mappings).&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 13:29:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2435192#M96950</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2024-03-27T13:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: joining with conditions</title>
      <link>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2435199#M96951</link>
      <description>&lt;P&gt;Hi Marcus!&lt;BR /&gt;&lt;BR /&gt;This is interesting. I still have not managed to do the solution using intervalmatch but i am getting closer.&lt;BR /&gt;&lt;BR /&gt;I would like to try your way but to do that here's a breakdown:&lt;BR /&gt;&lt;BR /&gt;My Table 1 &lt;STRONG&gt;"FACT"&amp;nbsp;&lt;/STRONG&gt;looks like this&lt;BR /&gt;MemberID, TransactionDate, TransactionNumber&lt;BR /&gt;&lt;BR /&gt;Table 2 -&amp;nbsp;&lt;STRONG&gt;"DIM"&lt;/STRONG&gt; looks like this:&lt;BR /&gt;MemberID, SubscriptionID, [Subscription Start Date], ActualEndDate, [Subscription Status]&lt;BR /&gt;&lt;BR /&gt;Since a memberID can have several subscription-id's, my goal is to map the right transactions with the right subscriptions.&lt;BR /&gt;I have built it correctly in SQL syntax as mentioned above, but havent found a way to do it with Qlik-syntax.&lt;BR /&gt;&lt;BR /&gt;What I want is to move all the fields from the DIM to the FACT and therefore I need to implement the rules that MemberID=MemberID &lt;STRONG&gt;AND&lt;/STRONG&gt; ActualEndDate&amp;gt;=TransactionDate &lt;STRONG&gt;AND&amp;nbsp;&lt;/STRONG&gt;TransactionDate&amp;gt;=[Subscription Start Date] while doing the joins/applymaps.&lt;BR /&gt;&lt;BR /&gt;If I try your way:&lt;BR /&gt;&lt;SPAN&gt;m: mapping load &lt;STRONG&gt;MemberID&lt;/STRONG&gt; &amp;amp; '|' &amp;amp; date(&lt;STRONG&gt;[TransactionDate]&lt;/STRONG&gt;&amp;nbsp;+ iterno() - 1),&amp;nbsp;&lt;STRONG&gt;[SubscriptionStartDate]&lt;/STRONG&gt; &amp;amp; '|' &amp;amp; &lt;STRONG&gt;[ActualEndDate]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;RESIDENT&amp;nbsp;&lt;STRONG&gt;DIM&lt;/STRONG&gt; &amp;nbsp;while &lt;STRONG&gt;TransactionDate&lt;/STRONG&gt;+ iterno() - 1 &amp;lt;= &lt;STRONG&gt;ActualEndDate&lt;/STRONG&gt;;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;I will get an error about TransactionDate not being part of the DIM-table...&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 13:57:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2435199#M96951</guid>
      <dc:creator>ismailk94</dc:creator>
      <dc:date>2024-03-27T13:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: joining with conditions</title>
      <link>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2435228#M96956</link>
      <description>&lt;P&gt;The loop-resolving of the dates should be against the Start- and End-Date from the DIM and not the Transaction-Date from the facts. The last is used within the applymap() to build there the lookup-value against the mapping-table:&lt;/P&gt;
&lt;P&gt;m: mapping load&amp;nbsp;MemberID&amp;nbsp;&amp;amp; '|' &amp;amp; date([&lt;STRONG&gt;SubscriptionStartDate&lt;/STRONG&gt;]&amp;nbsp;+ iterno() - 1),&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [SubscriptionStartDate]&amp;nbsp;&amp;amp; '|' &amp;amp;&amp;nbsp;[ActualEndDate]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;RESIDENT&amp;nbsp;DIM&amp;nbsp;&amp;nbsp;while &lt;STRONG&gt;SubscriptionStartDate&amp;nbsp;&lt;/STRONG&gt;+ iterno() - 1 &amp;lt;=&amp;nbsp;ActualEndDate;&lt;/P&gt;
&lt;P&gt;The general approach of using an internal while-loop to resolve a numeric range into single values as well as doing this with a mapping load will work - but in your described case of having multiple subscriptions per customer you could neither apply a mapping nor any join approach directly because it's not a 1:1 relationship else 1:n.&lt;/P&gt;
&lt;P&gt;A mapping will take only the first matching and all others will be ignored and a join would create duplicate records. Therefore a solution will need additionally measurements or another approach.&lt;/P&gt;
&lt;P&gt;Additionally measurements could mean to aggregate the subcription-id's and the various date-fields with concat() and using min/max on the date-fields to define the date-range and/or also counts + accumulations and/or offset-calculations between the multiple subscriptions. Many things are possible but it depends on the detailed requirements of the views what would be most suitable.&lt;/P&gt;
&lt;P&gt;Personally I would tend not to join/merge this DIM else keeping it as dimension-table within the data-model with the above mentioned:&lt;/P&gt;
&lt;P&gt;MemberID&amp;nbsp;&amp;amp; '|' &amp;amp; date([&lt;STRONG&gt;SubscriptionStartDate&lt;/STRONG&gt;]&amp;nbsp;+ iterno() - 1) as KEY&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as key between facts and dim and maybe applying afterwards a where exists() or an inner keep statement to the DIM to reduce the number of records.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 14:37:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/joining-with-conditions/m-p/2435228#M96956</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2024-03-27T14:37:43Z</dc:date>
    </item>
  </channel>
</rss>

