<?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: How to filter properly? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974825#M11731</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;- Assuming the answer to the previous question is "Yes" the modified code is below. Essentially you had it correct except that you cannot recalculate a variable, which is what you were trying to do. This is why you were getting the incorrect result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ModifiedCount = 
    VAR Metric = SUM('f_primary'[Count])
    VAR HasOneExpression = 
        OR ( 
            HASONEVALUE ( 'f_primary'[Field.1] ), 
            HASONEVALUE ( 'f_primary'[Field.2] ) 
        )
    VAR CalcHasOneFilter = 
        CALCULATE ( 
             SUM('f_primary'[Count]), 
            ALLEXCEPT ( 'f_primary', 'f_primary'[Field.1], 'f_primary'[Field.2], 'DateTbl'[Date] )
        ) 
    VAR CalcAll = CALCULATE ( SUM('f_primary'[Count]), ALLEXCEPT(f_primary, DateTbl[Date]))
RETURN
    IF ( HasOneExpression, CalcHasOneFilter, CalcAll )&lt;/LI-CODE&gt;</description>
    <pubDate>Sun, 15 Mar 2020 14:40:00 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2020-03-15T14:40:00Z</dc:date>
    <item>
      <title>How to filter properly?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974641#M11717</link>
      <description>&lt;P&gt;Edited per &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;suggestion. Thank you&lt;BR /&gt;&lt;BR /&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a report that I am attempting to provide the users with two seamlingly simple a simple [Count] and [Modified Count] measues. The [Count] measure has no filtering applied and would display whatever selections have been made by the user. The [Modified Count] field would have the starting population remain fixed, unless the user applies a filter to Field.1 or Field.2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I provided my current DAX expression for [Modified Count] and it does allow me to either modify the starting population by either Field.1 or Field.2, but the problem is that if i were to apply a filter in say Field.3 or Field.4 the starting population is also impacted(which is undesired).&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Also, for contect:&lt;BR /&gt;- I want the date selected to remain no matter what is selected. That is accounted for using the Values function.&lt;/P&gt;&lt;P&gt;- I am using the hasonevalue function to identify when Field.1 and Field.2 are selected.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Is someone able to recommend a solution for me to attempt to fix this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;BR /&gt;&lt;BR /&gt;f_primary table below. Assume this is a giant flat file that I havent created any relationship tables.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Item.ID&lt;/TD&gt;&lt;TD&gt;Field.1&lt;/TD&gt;&lt;TD&gt;Field.2&lt;/TD&gt;&lt;TD&gt;Field.3&lt;/TD&gt;&lt;TD&gt;Field.4&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;001&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;Blue&lt;/TD&gt;&lt;TD&gt;Dogs&lt;/TD&gt;&lt;TD&gt;PA&lt;/TD&gt;&lt;TD&gt;House&lt;/TD&gt;&lt;TD&gt;1/1/2019&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;002&lt;/TD&gt;&lt;TD&gt;Blue&lt;/TD&gt;&lt;TD&gt;Dogs&lt;/TD&gt;&lt;TD&gt;CA&lt;/TD&gt;&lt;TD&gt;House&lt;/TD&gt;&lt;TD&gt;4/1/2019&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;003&lt;/TD&gt;&lt;TD&gt;Red&lt;/TD&gt;&lt;TD&gt;Dogs&lt;/TD&gt;&lt;TD&gt;TX&lt;/TD&gt;&lt;TD&gt;Condo&lt;/TD&gt;&lt;TD&gt;10/1/2019&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;004&lt;/TD&gt;&lt;TD&gt;Blue&lt;/TD&gt;&lt;TD&gt;Dogs&lt;/TD&gt;&lt;TD&gt;MD&lt;/TD&gt;&lt;TD&gt;Condo&lt;/TD&gt;&lt;TD&gt;11/1/2019&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;005&lt;/TD&gt;&lt;TD&gt;Red&lt;/TD&gt;&lt;TD&gt;Cats&lt;/TD&gt;&lt;TD&gt;VA&lt;/TD&gt;&lt;TD&gt;House&lt;/TD&gt;&lt;TD&gt;11/1/2019&lt;/TD&gt;&lt;TD&gt;75&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;[ModifiedCount] =&lt;BR /&gt;VAR Metric = Sum(Count)&lt;BR /&gt;VAR HasOneExpression = OR ( HASONEVALUE ( f_primary[Field.1] ), HASONEVALUE ( f_primary[Field.2] ) )&lt;BR /&gt;VAR CalcHasOneFilter = CALCULATE ( Metric, ALLEXCEPT ( f_primary, f_primary[Field.1], f_primary[Field.2] ), VALUES ( DateTbl ) ) VAR CalcAll = CALCULATE ( Metric, ALL ( f_primary ), VALUES ( DateTbl ) )&lt;BR /&gt;&lt;BR /&gt;RETURN IF ( HasOneActual, CalcHasOneFilter, CalcAll )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scenarios I wish to see:&lt;/P&gt;&lt;P&gt;1) if the User has Field.4 = House. I should see the following:&lt;BR /&gt;[Count] = 185&lt;BR /&gt;[Modified Count] = 200&lt;BR /&gt;&lt;BR /&gt;2) if the User has Field.4 = House, and Field.1 = Blue.&amp;nbsp;I should see the following:&lt;/P&gt;&lt;P&gt;[Count] = 110&lt;BR /&gt;[Modified Count] = 130&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) if the User has Field.1 = Blue, and Field.2 = Dogs, and Field.3=PA.&amp;nbsp;I should see the following:&lt;/P&gt;&lt;P&gt;[Count] = 10&lt;BR /&gt;[Modified Count] = 120&amp;nbsp;&lt;/P&gt;&lt;P class="ics-element-donot-delete 1001_CC@"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Mar 2020 13:28:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974641#M11717</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-15T13:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter properly?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974654#M11718</link>
      <description>&lt;P&gt;Sounds like an ALLEXCEPT kind of situation. But, difficult to be sure with the information provided.&amp;nbsp;Please see this post regarding How to Get Your Question Answered Quickly: &lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Mar 2020 03:30:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974654#M11718</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-03-15T03:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter properly?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974787#M11723</link>
      <description>&lt;P&gt;Thank you for the suggested posting guidelines. I attempted to modify my post to make this more clear. I have searched around for this answer in the community and have watched many youtube/sqlbi clips and cant figure out what I am doiung wrong. Thank you for any assistance you are able to provide!&lt;/P&gt;</description>
      <pubDate>Sun, 15 Mar 2020 13:29:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974787#M11723</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-15T13:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter properly?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974809#M11728</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;Thanks for the edits. Taking a look now. Is your RETURN line supposed to read:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;RETURN IF ( HasOneExpression, CalcHasOneFilter, CalcAll )&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sun, 15 Mar 2020 14:07:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974809#M11728</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-03-15T14:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter properly?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974825#M11731</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;- Assuming the answer to the previous question is "Yes" the modified code is below. Essentially you had it correct except that you cannot recalculate a variable, which is what you were trying to do. This is why you were getting the incorrect result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ModifiedCount = 
    VAR Metric = SUM('f_primary'[Count])
    VAR HasOneExpression = 
        OR ( 
            HASONEVALUE ( 'f_primary'[Field.1] ), 
            HASONEVALUE ( 'f_primary'[Field.2] ) 
        )
    VAR CalcHasOneFilter = 
        CALCULATE ( 
             SUM('f_primary'[Count]), 
            ALLEXCEPT ( 'f_primary', 'f_primary'[Field.1], 'f_primary'[Field.2], 'DateTbl'[Date] )
        ) 
    VAR CalcAll = CALCULATE ( SUM('f_primary'[Count]), ALLEXCEPT(f_primary, DateTbl[Date]))
RETURN
    IF ( HasOneExpression, CalcHasOneFilter, CalcAll )&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 15 Mar 2020 14:40:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974825#M11731</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-03-15T14:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter properly?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974841#M11735</link>
      <description>"- I am using the hasonevalue function to identify when Field.1 and Field.2 are selected." To check if something has been selected from a column, it's best to use ISFILTERED, not HASONEVALUE. Actually, to see if only one value ahs been selected, you should use a combination of the two functions above.&lt;BR /&gt;&lt;BR /&gt;And then again... Please read this to see why you should not do what you do above: &lt;A href="https://www.sqlbi.com/articles/understanding-dax-auto-exist/" target="_blank"&gt;https://www.sqlbi.com/articles/understanding-dax-auto-exist/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Sun, 15 Mar 2020 15:06:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/974841#M11735</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-15T15:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter properly?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/975049#M11777</link>
      <description>&lt;P&gt;Thank you sir! I will test this out in a bit and see how it works. I knew i shouldnt have done that with the recalculated measure. I originally did that because I have to recreate this measure for other calculations and thought I could get by with copy/pasting the calculation and just changing the metric used at the top. I'll test and come back if this actually works to 'mark as solution'. Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 15 Mar 2020 21:49:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/975049#M11777</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-15T21:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter properly?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/975050#M11778</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;Anonymous&lt;/a&gt;. I will check that out today as well. Apparently my search was not inclusive enough. I really need to finish their DAX Masterclass...&lt;/P&gt;</description>
      <pubDate>Sun, 15 Mar 2020 22:00:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-properly/m-p/975050#M11778</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-15T22:00:46Z</dc:date>
    </item>
  </channel>
</rss>

