<?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: Conditional Join in PowerQuery Advanced editor? in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1336488#M42226</link>
    <description>&lt;P&gt;Unfortunately, I am not connecting to SQl server in this case. These data come from flat files. If I were connecting to SQL, I would do this join there.&lt;/P&gt;</description>
    <pubDate>Mon, 31 Aug 2020 15:11:50 GMT</pubDate>
    <dc:creator>McSarah</dc:creator>
    <dc:date>2020-08-31T15:11:50Z</dc:date>
    <item>
      <title>Conditional Join in PowerQuery Advanced editor?</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1329647#M42074</link>
      <description>&lt;P&gt;I am hoping to replicate the following SQL self join logic in Power Query (or DAX I guess) -- NOT as several sequential steps (join on A, create conditional column for B, filter on B conditional column, create condional column for C, filter on C conditional column...which I could easily do in the GUI), but in a way that actually avoids loading the unfiltered data on the inital A join -- because that intermediate data is huge and *extremely* slow to load, while the data with all three joins applied is managable. Most of the other threads I've seen on conditional joins seem to apply the conditions as additional steps, not in the initial join itself.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the SQL:&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;SELECT &lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A.ID&lt;/FONT&gt;&lt;FONT size="2"&gt;&amp;nbsp;,A.Date&amp;nbsp;&lt;/FONT&gt;&lt;FONT size="2"&gt;,A.State&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,B.ID&lt;/FONT&gt;&lt;FONT size="2"&gt;&amp;nbsp;,B.Date&lt;/FONT&gt;&lt;FONT size="2"&gt;,B.State&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;FROM DailyLog A&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;FULL OUTER JOIN DailyLog B&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;ON A.ID = B.ID AND A.Date &amp;lt;&amp;gt; B.Date AND A.State &amp;lt;&amp;gt; B.State&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I need to isolate records that show state changes for a given ID between any two dates. It might help to know that most IDs are present on most dates, but most IDs do not change state between most dates. Any date could have an ID that's not present on any other date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My thought was to do this transformation in Power Query , then use DAX to retrieve pertinent data for the IDs/ Dates/ States that actually land in this table. These data are not practical to load into SQL, or I'd do this data prep there.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 16:40:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1329647#M42074</guid>
      <dc:creator>McSarah</dc:creator>
      <dc:date>2020-08-27T16:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Join in PowerQuery Advanced editor?</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1329795#M42075</link>
      <description>&lt;P&gt;I am not aware of a way to set conditions like that in the join, but if you are connecting to SQL Server, this shouldn't be an issue. If you go "the long way" it should fold all of that and SQL Server do all of the work for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is not a SQL Server connection, but you are replicating SQL logic on text files, it won't matter. Processing it in the join or later is the same thing. Your statement "&lt;SPAN&gt;These data are not practical to load into SQL, or I'd do this data prep there." suggests you are doing this outside of SQL Server.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So if there is no db engine to do the processing, the Power Query mashupengine has to do all of the work. So if you have 1,000,000 records and only need 10 records it will have to read and discard the other 999,990 records. No way around that. That is the beauty of query folding with a server. You tell the server to do all of the work and just return 10 records.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 17:39:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1329795#M42075</guid>
      <dc:creator>edhans</dc:creator>
      <dc:date>2020-08-27T17:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Join in PowerQuery Advanced editor?</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1335833#M42196</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="199773" data-lia-user-login="McSarah" class="lia-mention lia-mention-user"&gt;McSarah&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you connect to SQL Server, how about typing your sql sode here?&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Reference:&amp;nbsp;&lt;A href="https://www.tutorialgateway.org/connect-power-bi-to-sql-server/" target="_self"&gt;Connect Power BI to SQL Server&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Icey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 10:37:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1335833#M42196</guid>
      <dc:creator>Icey</dc:creator>
      <dc:date>2020-08-31T10:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Join in PowerQuery Advanced editor?</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1336488#M42226</link>
      <description>&lt;P&gt;Unfortunately, I am not connecting to SQl server in this case. These data come from flat files. If I were connecting to SQL, I would do this join there.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 15:11:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1336488#M42226</guid>
      <dc:creator>McSarah</dc:creator>
      <dc:date>2020-08-31T15:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Join in PowerQuery Advanced editor?</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1336612#M42228</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="199773" data-lia-user-login="McSarah" class="lia-mention lia-mention-user"&gt;McSarah&lt;/a&gt;&amp;nbsp;then you cannot do this. Power Query must read&amp;nbsp;&lt;EM&gt;all&lt;/EM&gt; data in the flat files to know what to pull. There is no server available to handle that filtering for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you should never use that advanced SQL box. It has a number of bad side effects:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Can cause refresh issues in the service as your permissions have to be elevated.&lt;/LI&gt;
&lt;LI&gt;It breaks all further query folding in Power Query.&lt;/LI&gt;
&lt;LI&gt;It prevents Incremental Refresh from working at all.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Either do the full query in Power Query, or create a view on the SQL Server. Both will avoid all of the issues listed above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please mark one of these posts as the solution so this thread can be marked as solved to assist others that may be searching for similar info.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 15:43:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1336612#M42228</guid>
      <dc:creator>edhans</dc:creator>
      <dc:date>2020-08-31T15:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Join in PowerQuery Advanced editor?</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1336664#M42229</link>
      <description>&lt;P&gt;I am not trying to filter on the initial data pull from the files, I'm trying to filter inside a join downstream from the import -- I am comparing/ self joining tables after I've already imported and merged the source files into a single tall table. Power BI can handle the initial imports just fine; what I'm trying to avoid is getting an extremely large intermediate product on the downstream self join in Power Query.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 16:15:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1336664#M42229</guid>
      <dc:creator>McSarah</dc:creator>
      <dc:date>2020-08-31T16:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Join in PowerQuery Advanced editor?</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1336678#M42230</link>
      <description>&lt;P&gt;Perhaps if you shared some data and told us what your end goal was vs saying "this is how I do something in SQL, but Power Query won't do it" we could help. Power BI and SQL Server have a lot of the same logic, but self-joins in Power BI can be very inefficent. There may be other ways.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;But starting off with trying to make Product A behave the same as Product B can often take us down the wrong path.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to get good help fast. Help us help you.&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" rel="noopener" target="_blank"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" rel="noopener" target="_blank"&gt;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 16:20:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1336678#M42230</guid>
      <dc:creator>edhans</dc:creator>
      <dc:date>2020-08-31T16:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Join in PowerQuery Advanced editor?</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1336731#M42232</link>
      <description>&lt;P&gt;I just need to process the join I put in my original question in an efficient way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the purposes of this question we can assume that DailyLog is the &lt;U&gt;only&lt;/U&gt; table, and it &lt;U&gt;only&lt;/U&gt; contains three columns -- ProductID, Date, State.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The underlying table, DailyLog, is itself the result of a PowerQuery append operation on many underlying flat files--one per date--with identical format (ProductID, Date, State). These files were imported using a folder connection.&lt;/LI&gt;&lt;LI&gt;The need is to isolate all records where a product ID has different states on different days (where they had different states in different source flat files)&lt;/LI&gt;&lt;LI&gt;The issue is that the intermediate&lt;SPAN&gt;&amp;nbsp;PowerQuery product created by any one of the join conditions is huge because every component appears many time in the underlying table, while the combination of the three join conditions is relatively small. I can't just join on ProductID, or date&amp;lt;&amp;gt;date, or state&amp;lt;&amp;gt;state without blowing up the data. I want PBI to evaluate all three at once one way or another.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;If it were a regular join on three columns, I would just create one calculated column that combines the three source columns into one, then self join on that, but since the needed join is conditional, I'm having trouble wrapping my head around how this could work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's how I would do this in SQL:&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;SELECT&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A.ProductID&lt;/FONT&gt;&lt;FONT size="2"&gt;&amp;nbsp;,A.Date&amp;nbsp;&lt;/FONT&gt;&lt;FONT size="2"&gt;,A.State&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,B.ProductID&lt;/FONT&gt;&lt;FONT size="2"&gt;&amp;nbsp;,B.Date&lt;/FONT&gt;&lt;FONT size="2"&gt;,B.State&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;FROM DailyLog A&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;FULL OUTER JOIN DailyLog B&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT size="2"&gt;ON A.ID = B.ID AND A.Date &amp;lt;&amp;gt; B.Date AND A.State &amp;lt;&amp;gt; B.State&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 16:48:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1336731#M42232</guid>
      <dc:creator>McSarah</dc:creator>
      <dc:date>2020-08-31T16:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Join in PowerQuery Advanced editor?</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1337122#M42243</link>
      <description>&lt;P&gt;Well, without data, I am afraid we are talking in circles. I'd like to try to help, but I'm not great at just verbalizing or writing down how to do something without some hard data to show what I'm doing. The "picture is worth a thousand words" concept.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps someone more versed in SQL can do what you said in their head, then do the Power Query part in their head, then write down the answer you need.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 21:50:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Conditional-Join-in-PowerQuery-Advanced-editor/m-p/1337122#M42243</guid>
      <dc:creator>edhans</dc:creator>
      <dc:date>2020-08-31T21:50:03Z</dc:date>
    </item>
  </channel>
</rss>

