<?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: CALCULATE filters as filter function vs boolean expression in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-filters-as-filter-function-vs-boolean-expression/m-p/2416702#M63838</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="283692" data-lia-user-login="v-kkf-msft" class="lia-mention lia-mention-user"&gt;v-kkf-msft&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As mentioned in the question, I am getting different results between the filter method and the boolean expression.&amp;nbsp; That's why I am making the post.&amp;nbsp; When I use the boolean expression, my data is not filtered.&lt;/P&gt;</description>
    <pubDate>Fri, 25 Mar 2022 04:47:19 GMT</pubDate>
    <dc:creator>ghaines</dc:creator>
    <dc:date>2022-03-25T04:47:19Z</dc:date>
    <item>
      <title>CALCULATE filters as filter function vs boolean expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-filters-as-filter-function-vs-boolean-expression/m-p/2393673#M62362</link>
      <description>&lt;P&gt;I just fixed an issue and I don't understand how.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The brief was a unit count above and below our theoretical "minimum price" for a new order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used a simple boolean in a CALCULATE function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ASPStratifiedUnitsReturnValue = 
//Accounts for some deprecated items with the same product type
VAR HighestIndexInItemType = MAX('Pricing at Divisions'[ITEM_ID])
VAR PlatinumPrice = CALCULATE(MIN('Pricing at Divisions'[ITEM_UNIT_PRICE]),
    FILTER('Pricing at Divisions', 'Pricing at Divisions'[ITEM_ID] = HighestIndexInItemType)
)

RETURN
SWITCH(SELECTEDVALUE('_ASP Stratified Headings'[Ordering]),
    1, 
    CALCULATE([_UnitSalesFin],
        Transactions[Net Amount] &amp;gt;= PlatinumPrice
    ),
    2,
    CALCULATE([_UnitSalesFin],
        Transactions[Net Amount] &amp;lt; PlatinumPrice
    ),
    BLANK()
)&lt;/LI-CODE&gt;&lt;P&gt;It was to run in the context of a matrix with&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Product&lt;UL&gt;&lt;LI&gt;Platinum+ and below Platinum strata&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The 'Pricing at Divisions' table is only filtered by the product table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code did not work as intended, instead not applying the filters at all and returning the same value regardless of the headings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I changed to using the FILTER function e.g.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE([_UnitSalesFin],
        FILTER(Transactions, Transactions[Net Amount] &amp;gt;= PlatinumPrice)
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;then it worked as intended.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the difference?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 00:05:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-filters-as-filter-function-vs-boolean-expression/m-p/2393673#M62362</guid>
      <dc:creator>ghaines</dc:creator>
      <dc:date>2022-03-15T00:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: CALCULATE filters as filter function vs boolean expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-filters-as-filter-function-vs-boolean-expression/m-p/2393900#M62367</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="304963" data-lia-user-login="ghaines" class="lia-mention lia-mention-user"&gt;ghaines&lt;/a&gt; , I think this one should use allselected &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VAR PlatinumPrice = CALCULATE(MIN('Pricing at Divisions'[ITEM_UNIT_PRICE]),
    FILTER(allselected('Pricing at Divisions'), 'Pricing at Divisions'[ITEM_ID] = HighestIndexInItemType)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 15 Mar 2022 03:56:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-filters-as-filter-function-vs-boolean-expression/m-p/2393900#M62367</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-03-15T03:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: CALCULATE filters as filter function vs boolean expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-filters-as-filter-function-vs-boolean-expression/m-p/2393912#M62368</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;Thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It didn't fix the measure when the filters were changed back to simple booleans.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, whatever that intermediate variable was evaluating to, it doesn't seem to have any effect on the return value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The restriction Net_Amount &amp;gt;= PlatinumPrice returned all transactions in the context&lt;/P&gt;&lt;P&gt;The restriction Net_Amount &amp;lt; PlatinumPrice returned all transactions in the context&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The value of PlatinumPrice is immaterial. There is a mistake contained somewhere inside the Switch statement, and probably within a calculate function, since the default value of the switch was not returned except where appropriate.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 04:10:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-filters-as-filter-function-vs-boolean-expression/m-p/2393912#M62368</guid>
      <dc:creator>ghaines</dc:creator>
      <dc:date>2022-03-15T04:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: CALCULATE filters as filter function vs boolean expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-filters-as-filter-function-vs-boolean-expression/m-p/2399840#M62739</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="304963" data-lia-user-login="ghaines" class="lia-mention lia-mention-user"&gt;ghaines&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A Boolean expression used as a filter parameter in a &lt;A href="https://docs.microsoft.com/dax/calculate-function-dax" target="_self"&gt;CALCULATE&lt;/A&gt; function &lt;STRONG&gt;corresponds to an equivalent &lt;A href="https://docs.microsoft.com/dax/filter-function-dax" target="_self"&gt;FILTER&lt;/A&gt; expression&lt;/STRONG&gt; that operates on all the values of a column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This means that Equation&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CALCULATE([_UnitSalesFin],
        Transactions[Net Amount] &amp;lt; PlatinumPrice )&lt;/LI-CODE&gt;
&lt;P&gt;is actually equivalent to Equation&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CALCULATE([_UnitSalesFin],
        FILTER( ALL(Transactions[Net Amount]), Transactions[Net Amount] &amp;lt; PlatinumPrice ) )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more information, please refer to:&amp;nbsp;&lt;A href="https://www.sqlbi.com/blog/marco/2010/01/03/how-calculate-works-in-dax/" target="_self"&gt;How CALCULATE works in DAX&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.&lt;BR /&gt;Best Regards,&lt;BR /&gt;Winniz&lt;BR /&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 07:21:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-filters-as-filter-function-vs-boolean-expression/m-p/2399840#M62739</guid>
      <dc:creator>v-kkf-msft</dc:creator>
      <dc:date>2022-03-17T07:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: CALCULATE filters as filter function vs boolean expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-filters-as-filter-function-vs-boolean-expression/m-p/2416702#M63838</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="283692" data-lia-user-login="v-kkf-msft" class="lia-mention lia-mention-user"&gt;v-kkf-msft&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As mentioned in the question, I am getting different results between the filter method and the boolean expression.&amp;nbsp; That's why I am making the post.&amp;nbsp; When I use the boolean expression, my data is not filtered.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 04:47:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-filters-as-filter-function-vs-boolean-expression/m-p/2416702#M63838</guid>
      <dc:creator>ghaines</dc:creator>
      <dc:date>2022-03-25T04:47:19Z</dc:date>
    </item>
  </channel>
</rss>

