<?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 dynamically exclude records based on user defined conditions in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dynamically-exclude-records-based-on-user-defined-conditions/m-p/3668710#M142257</link>
    <description>&lt;P&gt;Hi all, and thank you for any suggestion with this little issue.&lt;/P&gt;&lt;P&gt;This is a semplified example, but my real model works the same way.&lt;/P&gt;&lt;P&gt;I have a projects table (every row is a project) and a Localizations table, in which every project has one row for each municipality involved.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The user can select one or more municipalities (Localizations[Municipality]) using a slicer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking for calculating the n. of projects and total budget of those projects localized &lt;STRONG&gt;only in one or more&lt;/STRONG&gt; of the municipalities the user selected, &lt;STRONG&gt;but not in any other&lt;/STRONG&gt; municipality not selected by the user.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Examples when the user choses municipalities A, B and C:&lt;BR /&gt;Project 1 localized in municipality A: included&lt;BR /&gt;Project 2 localized in municipality B: included&lt;BR /&gt;Project 3 localized in municipalities A and B: included&lt;BR /&gt;Project 4 localized in municipalities A, B and D : excluded&lt;BR /&gt;Project 5 localized in municipalities D and E: excluded&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I manage to calculate the n. of projects and their budget localized in at least in one of the municipalities the user selected, but this would include projects 1, 2, 3 and 4 of the example, while i need project D being excluded as it is localized also in municipality D which is not in the list the user selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you very much, any help is really appreciated.&lt;/P&gt;&lt;P&gt;Michele&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jan 2024 18:19:48 GMT</pubDate>
    <dc:creator>Michele_I</dc:creator>
    <dc:date>2024-01-30T18:19:48Z</dc:date>
    <item>
      <title>dynamically exclude records based on user defined conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dynamically-exclude-records-based-on-user-defined-conditions/m-p/3668710#M142257</link>
      <description>&lt;P&gt;Hi all, and thank you for any suggestion with this little issue.&lt;/P&gt;&lt;P&gt;This is a semplified example, but my real model works the same way.&lt;/P&gt;&lt;P&gt;I have a projects table (every row is a project) and a Localizations table, in which every project has one row for each municipality involved.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The user can select one or more municipalities (Localizations[Municipality]) using a slicer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking for calculating the n. of projects and total budget of those projects localized &lt;STRONG&gt;only in one or more&lt;/STRONG&gt; of the municipalities the user selected, &lt;STRONG&gt;but not in any other&lt;/STRONG&gt; municipality not selected by the user.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Examples when the user choses municipalities A, B and C:&lt;BR /&gt;Project 1 localized in municipality A: included&lt;BR /&gt;Project 2 localized in municipality B: included&lt;BR /&gt;Project 3 localized in municipalities A and B: included&lt;BR /&gt;Project 4 localized in municipalities A, B and D : excluded&lt;BR /&gt;Project 5 localized in municipalities D and E: excluded&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I manage to calculate the n. of projects and their budget localized in at least in one of the municipalities the user selected, but this would include projects 1, 2, 3 and 4 of the example, while i need project D being excluded as it is localized also in municipality D which is not in the list the user selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you very much, any help is really appreciated.&lt;/P&gt;&lt;P&gt;Michele&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 18:19:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dynamically-exclude-records-based-on-user-defined-conditions/m-p/3668710#M142257</guid>
      <dc:creator>Michele_I</dc:creator>
      <dc:date>2024-01-30T18:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically exclude records based on user defined conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dynamically-exclude-records-based-on-user-defined-conditions/m-p/3668834#M142260</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="204659" data-lia-user-login="Michele_I" class="lia-mention lia-mention-user"&gt;Michele_I&lt;/a&gt;&amp;nbsp;Maybe something like this. See PBIX attached below signature.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Selection Measure = 
    VAR __Municipalities = SELECTCOLUMNS('Municipalities', "municipality", [municipality])
    VAR __ProjectID = MAX('Projects'[projectID])
    VAR __Localizations = SELECTCOLUMNS(FILTER(ALL('Localizations'), [projectID] = __ProjectID), "__municipality", [municipality])
    VAR __Except = EXCEPT(__Localizations, __Municipalities)
    VAR __Intersect = INTERSECT(__Localizations, __Municipalities)
    VAR __Result = IF(COUNTROWS(__Except) = BLANK() &amp;amp;&amp;amp; COUNTROWS(__Intersect) &amp;lt;&amp;gt; BLANK(), 1, 0)
RETURN
    __Result&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 Jan 2024 18:45:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dynamically-exclude-records-based-on-user-defined-conditions/m-p/3668834#M142260</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2024-01-30T18:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically exclude records based on user defined conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dynamically-exclude-records-based-on-user-defined-conditions/m-p/3668979#M142278</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;thank you very much for helping me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to your code i could get the table you see on the left, which correctly associates value 1 to projectIDs matching the requirements. Budget total is 100 but if i filter the table for "selection measure" = 1 i correctly get 60. I would never get here without your help!&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This all works fine in a table with one record per project, but how can i use your code to build a measure that automatically calculates a total budget of 60 when municipalities A and B are selected?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To achieve this i tried adding some more code (it seems fine to me but i'm not sure):&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;budget ok = VAR __Municipalities = SELECTCOLUMNS('Municipalities', "municipality", [municipality]) 
    VAR __ProjectID = MAX('Projects'[projectID])
    VAR __Localizations = SELECTCOLUMNS(FILTER(ALL('Localizations'), [projectID] = __ProjectID), "__municipality", [municipality]) 
    VAR __Except = EXCEPT(__Localizations, __Municipalities) 
    VAR __Intersect = INTERSECT(__Localizations, __Municipalities)
    VAR __Result = IF(COUNTROWS(__Except) = BLANK() &amp;amp;&amp;amp; COUNTROWS(__Intersect) &amp;lt;&amp;gt; BLANK(), 1, 0)

    var __projecttable = ADDCOLUMNS(Projects,"Check",[Selection Measure])
    var __filteredprojecttable = FILTER(__projecttable, [Check]=1)

return

CALCULATE(SUM(Projects[budget]),__filteredprojecttable)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this the right way to use your tips?&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 20:52:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dynamically-exclude-records-based-on-user-defined-conditions/m-p/3668979#M142278</guid>
      <dc:creator>Michele_I</dc:creator>
      <dc:date>2024-01-30T20:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically exclude records based on user defined conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dynamically-exclude-records-based-on-user-defined-conditions/m-p/3668991#M142279</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="204659" data-lia-user-login="Michele_I" class="lia-mention lia-mention-user"&gt;Michele_I&lt;/a&gt;&amp;nbsp;Well, if it works, it works. Probably not how I would have done it. I would have probably done something like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Budget OK = 
  VAR __Table = FILTER( ADDCOLUMNS('Projects', "__Selected", [Selection Measure]), [__Selected] = 1)
  VAR __Result = SUMX(__Table, [budget])
RETURN
  __Result&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 Jan 2024 21:00:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dynamically-exclude-records-based-on-user-defined-conditions/m-p/3668991#M142279</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2024-01-30T21:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically exclude records based on user defined conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dynamically-exclude-records-based-on-user-defined-conditions/m-p/3669022#M142283</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;Your way is much better &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 21:26:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dynamically-exclude-records-based-on-user-defined-conditions/m-p/3669022#M142283</guid>
      <dc:creator>Michele_I</dc:creator>
      <dc:date>2024-01-30T21:26:10Z</dc:date>
    </item>
  </channel>
</rss>

