<?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: Creating a variable as filter based on a sql subselect in  power bi in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-a-variable-as-filter-based-on-a-sql-subselect-in-power/m-p/4061012#M161193</link>
    <description>&lt;P&gt;Hey:) thx a lot. I didn't expect an answer that fast and usefull as yours! Yes i think this will do the job. And the menu with the available slicers looks good, too. Meanwhile, since i was born with sql;) i created a column in the result table (on db) with the listagg function. So every prev and next combo is in this column as a string. Now i can use an advanced filter and type the keyword into the prompt. Not the best nor fastest solution but it works too. I implement your solution where it's possible (not too many possible keywords). Thx a lot&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2024 09:14:10 GMT</pubDate>
    <dc:creator>Rumsch</dc:creator>
    <dc:date>2024-07-25T09:14:10Z</dc:date>
    <item>
      <title>Creating a variable as filter based on a sql subselect in  power bi</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-a-variable-as-filter-based-on-a-sql-subselect-in-power/m-p/4057356#M161028</link>
      <description>&lt;P&gt;Hey everyone, i'm comming from oracle pl/sql and i'm building a dashboard in power bi desktop. I connected an oracle db and what i need to do is to create a variable that can be used to filter unique id's. The data looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Id, prev, next, date prev, date next&lt;/P&gt;&lt;P&gt;A1,&amp;nbsp; nl, ger, 01.01.24, 03.01.24&lt;/P&gt;&lt;P&gt;A1, ger, swe, 03.01.24, 10.01.24&lt;/P&gt;&lt;P&gt;A1, swe, fr, 10.01.24, 15.01.24&lt;/P&gt;&lt;P&gt;A2, fr, ger, 02.02.24, 10.02.24&lt;/P&gt;&lt;P&gt;A2, ger, us, 10.02.24, 20.02.24&lt;/P&gt;&lt;P&gt;A3, us, can, 17.01.24, 30.01.24&lt;/P&gt;&lt;P&gt;A3, can, ger, 30.01.24, 10.02.24&lt;/P&gt;&lt;P&gt;And so on....&lt;/P&gt;&lt;P&gt;In sql the statement looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Select sq1.*&lt;/P&gt;&lt;P&gt;from table sq1&lt;/P&gt;&lt;P&gt;, (select id from table where prev='ger') sq2&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where sq1.id=sq2.id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So i need to filter all rows containing the id from the table by useing a subselect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition to that, i need a filter in the dasboard, where the user can fill in the prev='ger' as a variable. In pl/sql i use a stored procedure with variables and do a call like call p_1(var1, var2, var3);&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've seen some similar questions regarding subselects but not in combination with variable filters. Thx in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 21:38:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-a-variable-as-filter-based-on-a-sql-subselect-in-power/m-p/4057356#M161028</guid>
      <dc:creator>Rumsch</dc:creator>
      <dc:date>2024-07-23T21:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a variable as filter based on a sql subselect in  power bi</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-a-variable-as-filter-based-on-a-sql-subselect-in-power/m-p/4057652#M161039</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="779737" data-lia-user-login="Rumsch" class="lia-mention lia-mention-user"&gt;Rumsch&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry, so far, to my knowledge, this may not be achieveable.&lt;/P&gt;
&lt;P&gt;I suggest you create a slicer to manually filter the [prev].&lt;/P&gt;
&lt;P&gt;(1)&amp;nbsp;This is my test data. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(2) We can create a measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Flag = IF(MAX('sq1'[Id]) in VALUES('sq2'[Id]),1,0)&lt;/LI-CODE&gt;
&lt;P&gt;(3)&amp;nbsp;Place [Flag=1] on the screening of the visual object.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;You can manually select the value on the [prev] slicer, with prev=ger in the screenshot, and the table will output the ids that exist in both the sq1 and sq2 tables with prev=ger.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution &lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 06:10:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-a-variable-as-filter-based-on-a-sql-subselect-in-power/m-p/4057652#M161039</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-24T06:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a variable as filter based on a sql subselect in  power bi</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-a-variable-as-filter-based-on-a-sql-subselect-in-power/m-p/4061012#M161193</link>
      <description>&lt;P&gt;Hey:) thx a lot. I didn't expect an answer that fast and usefull as yours! Yes i think this will do the job. And the menu with the available slicers looks good, too. Meanwhile, since i was born with sql;) i created a column in the result table (on db) with the listagg function. So every prev and next combo is in this column as a string. Now i can use an advanced filter and type the keyword into the prompt. Not the best nor fastest solution but it works too. I implement your solution where it's possible (not too many possible keywords). Thx a lot&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 09:14:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-a-variable-as-filter-based-on-a-sql-subselect-in-power/m-p/4061012#M161193</guid>
      <dc:creator>Rumsch</dc:creator>
      <dc:date>2024-07-25T09:14:10Z</dc:date>
    </item>
  </channel>
</rss>

