<?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 doesn't work correctly -  FILTER (beginner question) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872181#M92737</link>
    <description>&lt;P&gt;No, its not working, this is not the case, I have checked it twice&lt;/P&gt;</description>
    <pubDate>Sat, 29 Oct 2022 11:33:32 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-10-29T11:33:32Z</dc:date>
    <item>
      <title>Calculate doesn't work correctly -  FILTER (beginner question)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872160#M92731</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I have beginner question, maybe I don't understand something in correct way.&lt;/P&gt;&lt;P&gt;I have to calculate count of products above average price.&lt;/P&gt;&lt;P&gt;I have tried to calculate that in this way:&lt;/P&gt;&lt;P&gt;avgprice = average(Products[UnitPrice])&lt;/P&gt;&lt;P&gt;countofproducts = calculate(count(Products[ProductID]),filter(Products,Product[UnitPrice]&amp;gt;avgprice))&lt;/P&gt;&lt;P&gt;solution above gives me blank and I don't understand why&lt;/P&gt;&lt;P&gt;when I calculate it that way it works correctly:&lt;/P&gt;&lt;P&gt;countofproducts2 = calculate(count(Products[ProductID]),filter(Products,Product[UnitPrice]&amp;gt;average(Products[UnitPrice])&lt;/P&gt;&lt;P&gt;So why cannot I calculate it in the first way? Even if I put calculate(average(Products[UnitPrice])) it doesn't work correctly &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;could you explain it to me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 11:06:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872160#M92731</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-29T11:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate doesn't work correctly -  FILTER (beginner question)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872171#M92732</link>
      <description>&lt;P&gt;Hello please try&lt;/P&gt;&lt;P&gt;calculate(count(Products[ProductID]),Maxx(products,Product[UnitPrice]&amp;gt;avgprice))&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 11:21:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872171#M92732</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-29T11:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate doesn't work correctly -  FILTER (beginner question)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872175#M92734</link>
      <description>&lt;P&gt;Thanks, but I'm not asking for solution, I'm asking for explanation why my solution didn't work&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 11:29:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872175#M92734</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-29T11:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate doesn't work correctly -  FILTER (beginner question)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872177#M92736</link>
      <description>&lt;P&gt;Hi, maybe you forgot a letter s in the filter of the calculate. You wrote Product[UnitPrice] instead Products[UnitPrice].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;avgprice = average(Products[UnitPrice])&lt;/P&gt;&lt;P&gt;countofproducts = calculate(count(Products[ProductID]),filter(Products,Product[UnitPrice]&amp;gt;avgprice))&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 11:30:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872177#M92736</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-29T11:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate doesn't work correctly -  FILTER (beginner question)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872181#M92737</link>
      <description>&lt;P&gt;No, its not working, this is not the case, I have checked it twice&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 11:33:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872181#M92737</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-29T11:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate doesn't work correctly -  FILTER (beginner question)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872192#M92738</link>
      <description>&lt;P&gt;Ok, i dont know if in countofproducts is necesary the filter:&lt;/P&gt;&lt;P&gt;Maybe that is the problem, i would use the following formula:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;countofproducts = calculate(count(Products[ProductID]),Product[UnitPrice]&amp;gt;avgprice))&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 11:40:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872192#M92738</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-29T11:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate doesn't work correctly -  FILTER (beginner question)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872193#M92739</link>
      <description>&lt;P&gt;When you use a measure in DAX, the DAX will wrap the measure in a CALCULATE. CALCULATE transforms the current row context into a filter context.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The FILTER function introduces a row context. This is important. The FILTER function iterates through the table used as the first parameter row by row and tests the expression used as the 2nd argument. If you use a measure in the expression, the measure will be wrapped in a CALCULATE and the current row context introduced by FILTER will be turned into a filter context and passed to the measure. This means that the measure will always evaluate in a filter context defined by the current row context of the FILTER function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason why setting the measure to a variable bypasses this is that the value associated with the measure outside of any row context is saved to the variable and so it will stay constant and be uninfluenced by row context (if using the FILTER function). It also often allows you to bypass the need for the FILTER function in a CALCULATE to begin with as the expression in a CALCULATE has some drawbacks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Filter desired =
VAR avgprice = average(Products[UnitPrice])

Return
calculate(count(Products[ProductID]),filter(Products,Product[UnitPrice]&amp;gt;avgprice))&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 29 Oct 2022 11:40:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872193#M92739</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-29T11:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate doesn't work correctly -  FILTER (beginner question)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872223#M92740</link>
      <description>&lt;P&gt;Great answer, thank you buddy! So, if I understood correctly, I cannot use measure when comparing in FILTER function because measure which has filter context will evaluate into row context in every row (when iterating with filter)? So the constant value in measure avgprice will always be evaluated into value based in filter context which comes from row context?&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 12:11:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-doesn-t-work-correctly-FILTER-beginner-question/m-p/2872223#M92740</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-29T12:11:11Z</dc:date>
    </item>
  </channel>
</rss>

