<?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: Calculating difference from filtered mean/average in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-difference-from-filtered-mean-average/m-p/1629203#M32987</link>
    <description>&lt;P&gt;Thanks, that did the trick.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jan 2021 14:07:39 GMT</pubDate>
    <dc:creator>AlanRGroskreutz</dc:creator>
    <dc:date>2021-01-28T14:07:39Z</dc:date>
    <item>
      <title>Calculating difference from filtered mean/average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-difference-from-filtered-mean-average/m-p/1628949#M32972</link>
      <description>&lt;P&gt;I am stuck trying to create either a calculated column or a measure that will give me an array of values calculated from two columns in a table.&amp;nbsp; The first column contains the groups in which the values fall (Group), and the second contains the values (Value).&amp;nbsp; What I want to do is to calculate the mode of the values per group and then, per row, subtract the value from that mode.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here is an example of how the calculations would look (the column Mode/Group isn't necessary and can be a variable)&lt;BR /&gt;&lt;STRONG&gt;'Data table'&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Group&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;TD&gt;&lt;EM&gt;Mode/group&lt;/EM&gt;&lt;/TD&gt;&lt;TD&gt;&lt;EM&gt;Calculated Value&lt;/EM&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to be able to later show the maximum, minimum, and average value of this difference per group, and also to be able to filter it for other columns in this table. Therefore I'm not sure if a calculated column or a measure would be better.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for any help.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 11:57:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-difference-from-filtered-mean-average/m-p/1628949#M32972</guid>
      <dc:creator>AlanRGroskreutz</dc:creator>
      <dc:date>2021-01-28T11:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating difference from filtered mean/average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-difference-from-filtered-mean-average/m-p/1628997#M32976</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="124493" data-lia-user-login="AlanRGroskreutz" class="lia-mention lia-mention-user"&gt;AlanRGroskreutz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this for your calculated column&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;New column =
VAR mode_ =
    MINX (
        TOPN (
            1,
            CALCULATETABLE (
                ADDCOLUMNS (
                    DISTINCT ( Table1[Value] ),
                    "Frequency", CALCULATE ( COUNT ( Table1[Value] ) )
                ),
                ALLEXCEPT ( Table1, Table1[Group] )
            ),
            [Frequency], 0
        ),
        Table1[Value]
    )
RETURN
    Table1[Value] - mode_
&lt;/LI-CODE&gt;
&lt;P&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;and check this out for the MODE pattern&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.daxpatterns.com/statistical-patterns/#" target="_blank" rel="noopener"&gt;https://www.daxpatterns.com/statistical-patterns/#&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="height: 100px; width: 100%; border-collapse: collapse; border-style: groove; border-color: #0c1c49; background-color: #00675f;" border="0" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15px;"&gt;
&lt;TD width="15.961305925030231%" style="width: 92px; height: 15px;"&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="84.03869407496977%" style="width: 485px; height: 15px; text-align: left;"&gt;&lt;FONT color="#FFFFFF"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Please accept the solution when done and consider &lt;FONT color="#FF9900"&gt;giving a thumbs up if posts are helpful.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color="#FFFFFF"&gt;&lt;SPAN style="color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt; &lt;/FONT&gt;&lt;BR /&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4.5" color="#FF99CC"&gt;Contact me privately for support with any larger-scale BI needs, tutoring, etc.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3" color="#FF99CC"&gt;&lt;FONT color="#FFFFFF"&gt;&lt;SPAN style="color: #ffffff;"&gt;Cheers&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 14:08:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-difference-from-filtered-mean-average/m-p/1628997#M32976</guid>
      <dc:creator>AlB</dc:creator>
      <dc:date>2021-01-28T14:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating difference from filtered mean/average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-difference-from-filtered-mean-average/m-p/1629203#M32987</link>
      <description>&lt;P&gt;Thanks, that did the trick.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 14:07:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-difference-from-filtered-mean-average/m-p/1629203#M32987</guid>
      <dc:creator>AlanRGroskreutz</dc:creator>
      <dc:date>2021-01-28T14:07:39Z</dc:date>
    </item>
  </channel>
</rss>

