<?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: Filtering by max value within calculated table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filtering-by-max-value-within-calculated-table/m-p/2291291#M56323</link>
    <description>&lt;P&gt;No takers? Is it not possible? Do I have to do a calculated column and then create a new calculated table applying the desired filter?&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jan 2022 14:19:03 GMT</pubDate>
    <dc:creator>MJEnnis</dc:creator>
    <dc:date>2022-01-19T14:19:03Z</dc:date>
    <item>
      <title>Filtering by max value within calculated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filtering-by-max-value-within-calculated-table/m-p/2290471#M56291</link>
      <description>&lt;P&gt;I have a calculated table that works something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var TAB1 = SELECTCOLUMNS(...&lt;/P&gt;&lt;P&gt;Var TAB2 = ADDCOLUMNS(...&lt;/P&gt;&lt;P&gt;RETURN TAB2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The resulting table is something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;LEVEL1&lt;/TD&gt;&lt;TD&gt;LEVEL2&lt;/TD&gt;&lt;TD&gt;LEVEL3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1890&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4567&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4567&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to filter out the the lower summed level rows for each duplicated ID. (Never more than two occurences of each ID. And only 20 duplicates in a table with over 23000 rows. But I urgently need to remove these duplicated entries.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The easiest solution to me seems to be to create a LEVEL_SUM column and then to filter out the rows where the the sum does not equal the max value for each ID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This of course works fine:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var TAB3 = ADDCOLUMNS(TAB2, "LEVEL_SUM", [LEVEL 1] + [LEVEL 2] + [LEVEL 3])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, since this is all within the same code for a calculated table, the following will not work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var TEMPID = [ID]&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&amp;nbsp;# &amp;lt;= PROBLEM IS HERE! This is not yet a column, but a column expression.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a result, none of the rest will work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var TAB4 = ADDCOLUMNS(TAB3, "MAX_LEVEL", Maxx(FILTER(TAB3, [ID] = TEMPID), [LEVEL_SUM]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var TAB5 = FILTER(TAB4, [MAX_LEVEL] = [LEVEL_SUM])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RETURN TAB5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any crafty tips to do this without creating a separate calculated table and without Power Query? This would probably work as a calculated column instead, but the problem is that I have to "wrangle" the data a lot more after I filter these rows out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 08:13:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filtering-by-max-value-within-calculated-table/m-p/2290471#M56291</guid>
      <dc:creator>MJEnnis</dc:creator>
      <dc:date>2022-01-19T08:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering by max value within calculated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filtering-by-max-value-within-calculated-table/m-p/2291291#M56323</link>
      <description>&lt;P&gt;No takers? Is it not possible? Do I have to do a calculated column and then create a new calculated table applying the desired filter?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 14:19:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filtering-by-max-value-within-calculated-table/m-p/2291291#M56323</guid>
      <dc:creator>MJEnnis</dc:creator>
      <dc:date>2022-01-19T14:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering by max value within calculated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filtering-by-max-value-within-calculated-table/m-p/2291316#M56324</link>
      <description>&lt;P&gt;This works perfectly as a calculated column:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Max Levels =&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Var TEMPID = [ID]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Var MAX_LEVELS =&amp;nbsp;Maxx(FILTER(TAB3, [ID] = TEMPID), [LEVEL_SUM])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RETURN MAX_LEVELS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But then I have to create a new calculated table that filters for Level Sum = Max Level. I already have more tables than I can manage in my model.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where are the real gurus today?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 14:36:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filtering-by-max-value-within-calculated-table/m-p/2291316#M56324</guid>
      <dc:creator>MJEnnis</dc:creator>
      <dc:date>2022-01-19T14:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering by max value within calculated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filtering-by-max-value-within-calculated-table/m-p/2291610#M56341</link>
      <description>&lt;P&gt;I think something like this should work:&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;CalculatedTable =
VAR TAB1 = SELECTCOLUMNS ( [...] )
VAR TAB2 = ADDCOLUMNS ( TAB1, [...] )
VAR TAB3 = ADDCOLUMNS ( TAB2, "LEVEL_SUM", [LEVEL 1] + [LEVEL 2] + [LEVEL 3] )
RETURN
    FILTER (
        TAB3,
        [LEVEL_SUM]
            = MAXX ( FILTER ( TAB3, [ID] = EARLIER ( [ID] ) ), [LEVEL_SUM] )
    )&lt;/LI-CODE&gt;
&lt;P&gt;But I haven't checked it against anything&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 16:52:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filtering-by-max-value-within-calculated-table/m-p/2291610#M56341</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2022-01-19T16:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering by max value within calculated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filtering-by-max-value-within-calculated-table/m-p/2291662#M56346</link>
      <description>&lt;P&gt;Works like a charm! Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just added it as a new variable, instead of as a filter on the resulting table, as I still have some more steps to take before the table is ready.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 17:26:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filtering-by-max-value-within-calculated-table/m-p/2291662#M56346</guid>
      <dc:creator>MJEnnis</dc:creator>
      <dc:date>2022-01-19T17:26:49Z</dc:date>
    </item>
  </channel>
</rss>

