<?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 Rank based on more tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Rank-based-on-more-tables/m-p/915602#M8876</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="64216" data-lia-user-login="soldous" class="lia-mention lia-mention-user"&gt;soldous&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THank you for sharing your pbix. I won't share it back here but I do want to shar ethe solution as it might inspire others on similar questions.&amp;nbsp;&lt;BR /&gt;To be honest, I don't know if this is the best solution to this problem but it works (and that is better then what you currently have, I suppose :P)&lt;/P&gt;&lt;P&gt;THe measure is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rank = 
VAR _tmpTable = SUMMARIZE(ALL(FactFeedback), DimModelYear[Year], DimModel[ModelCategory], "sentiment", [Senstiment])
VAR _curYear = SELECTEDVALUE(DimModelYear[Year])
VAR _curModel = SELECTEDVALUE(DimModel[ModelCategory])
VAR _rankedTable = ADDCOLUMNS(FILTER(_tmpTable, [ModelCategory] &amp;lt;&amp;gt; BLANK()), "rank", 
    VAR _curTmptableYear = [Year]
    RETURN
    RANKX(FILTER(_tmpTable, [Year]=_curTmptableYear), [sentiment],,ASC,Dense))
RETURN
MAXX(FILTER(_rankedTable, [Year] = _curYear &amp;amp;&amp;amp; [ModelCategory] = _curModel), [rank])&lt;/LI-CODE&gt;&lt;P&gt;I will have to explain tomorrow what is happening here because I have to sleep, but here is a screengrab of your matrix where it is in action. If you want the rank to be reverserd, change ASC into DESC in the above measure &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Like I said, I looooove ranking questions, they are a lot of fun &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Have a good night!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Djerro123&lt;/P&gt;&lt;P&gt;-------------------------------&lt;/P&gt;&lt;P&gt;If this answered your question, please &lt;STRONG&gt;mark it as the Solution&lt;/STRONG&gt;. This also helps others to find what they are looking for.&lt;/P&gt;&lt;P&gt;Keep those &lt;STRONG&gt;thumbs up&lt;/STRONG&gt; coming! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jan 2020 21:07:28 GMT</pubDate>
    <dc:creator>JarroVGIT</dc:creator>
    <dc:date>2020-01-29T21:07:28Z</dc:date>
    <item>
      <title>Calculate Rank based on more tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Rank-based-on-more-tables/m-p/915509#M8870</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 3 related tables.&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;DimModel for all Item models&lt;/LI&gt;&lt;LI&gt;DimModelYear for all years each model was created&lt;/LI&gt;&lt;LI&gt;FactFeedback where models are rated&lt;UL&gt;&lt;LI&gt;In this table, a measure sentiment is calculated based on good/bad rating&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to calculated Rank for each model in each year based on the sentiment value.&lt;/P&gt;&lt;P&gt;Could you please help me with this DAX? I saw many RANKX examples but couldn't bend any to my needs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thousand thanks in advance.&lt;/P&gt;&lt;P&gt;Zdenek&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2020 19:39:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Rank-based-on-more-tables/m-p/915509#M8870</guid>
      <dc:creator>soldous</dc:creator>
      <dc:date>2020-01-29T19:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Rank based on more tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Rank-based-on-more-tables/m-p/915547#M8871</link>
      <description>&lt;P&gt;It is almost impossible to help you without knowing what your (relevant) data structure looks like. What columns are we talking about? Can you give a few lines of data of the FactFeedback table and the corresponding rank you expect?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The best way would be sharing a PBIX with dummy (or real, if there is no confidential data!) data, is that possible? You can even PM me a link if you don't want to share publicly, I love RANKX questions &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Djerro123&lt;/P&gt;&lt;P&gt;-------------------------------&lt;/P&gt;&lt;P&gt;If this answered your question, please &lt;STRONG&gt;mark it as the Solution&lt;/STRONG&gt;. This also helps others to find what they are looking for.&lt;/P&gt;&lt;P&gt;Keep those &lt;STRONG&gt;thumbs up&lt;/STRONG&gt; coming! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2020 20:14:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Rank-based-on-more-tables/m-p/915547#M8871</guid>
      <dc:creator>JarroVGIT</dc:creator>
      <dc:date>2020-01-29T20:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Rank based on more tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Rank-based-on-more-tables/m-p/915602#M8876</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="64216" data-lia-user-login="soldous" class="lia-mention lia-mention-user"&gt;soldous&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THank you for sharing your pbix. I won't share it back here but I do want to shar ethe solution as it might inspire others on similar questions.&amp;nbsp;&lt;BR /&gt;To be honest, I don't know if this is the best solution to this problem but it works (and that is better then what you currently have, I suppose :P)&lt;/P&gt;&lt;P&gt;THe measure is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rank = 
VAR _tmpTable = SUMMARIZE(ALL(FactFeedback), DimModelYear[Year], DimModel[ModelCategory], "sentiment", [Senstiment])
VAR _curYear = SELECTEDVALUE(DimModelYear[Year])
VAR _curModel = SELECTEDVALUE(DimModel[ModelCategory])
VAR _rankedTable = ADDCOLUMNS(FILTER(_tmpTable, [ModelCategory] &amp;lt;&amp;gt; BLANK()), "rank", 
    VAR _curTmptableYear = [Year]
    RETURN
    RANKX(FILTER(_tmpTable, [Year]=_curTmptableYear), [sentiment],,ASC,Dense))
RETURN
MAXX(FILTER(_rankedTable, [Year] = _curYear &amp;amp;&amp;amp; [ModelCategory] = _curModel), [rank])&lt;/LI-CODE&gt;&lt;P&gt;I will have to explain tomorrow what is happening here because I have to sleep, but here is a screengrab of your matrix where it is in action. If you want the rank to be reverserd, change ASC into DESC in the above measure &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Like I said, I looooove ranking questions, they are a lot of fun &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Have a good night!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Djerro123&lt;/P&gt;&lt;P&gt;-------------------------------&lt;/P&gt;&lt;P&gt;If this answered your question, please &lt;STRONG&gt;mark it as the Solution&lt;/STRONG&gt;. This also helps others to find what they are looking for.&lt;/P&gt;&lt;P&gt;Keep those &lt;STRONG&gt;thumbs up&lt;/STRONG&gt; coming! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2020 21:07:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Rank-based-on-more-tables/m-p/915602#M8876</guid>
      <dc:creator>JarroVGIT</dc:creator>
      <dc:date>2020-01-29T21:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Rank based on more tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Rank-based-on-more-tables/m-p/915609#M8877</link>
      <description>&lt;P&gt;Thank you very much Djerro!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are the best! Also if you had a better solution I would like to hear it. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2020 21:10:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Rank-based-on-more-tables/m-p/915609#M8877</guid>
      <dc:creator>soldous</dc:creator>
      <dc:date>2020-01-29T21:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Rank based on more tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Rank-based-on-more-tables/m-p/918232#M8957</link>
      <description>&lt;P&gt;So&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="64216" data-lia-user-login="soldous" class="lia-mention lia-mention-user"&gt;soldous&lt;/a&gt; aproached me with a very valid question; this measure will not recalculate the rank based on a filtered selection of Models. The key bit here is the ALL() statement in the first argument of SUMMARIZE(). This removes any filters applied to the query FactFeedback. If you create a slicer on DimModel[ModelCategory], that will implicitely filter the FactFeedback query. Then using ALL will result in that Model8 in 2020 always have rank=5, regardless of the selected models in the DimModel[ModelCategory] slicer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This can be circumvented by replacing ALL by ALLSELECTED(). This removes any filters of inside the query (so inside the measure), but retains all filters from outside the measure (for example, a filter caused by a slicer). The result is&amp;nbsp; this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;So, for completion here is the measure using ALLSELECTED:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rank = 
VAR _tmpTable = SUMMARIZE(ALLSELECTED(FactFeedback), DimModelYear[Year], DimModel[ModelCategory], "sentiment", [Senstiment])
VAR _curYear = SELECTEDVALUE(DimModelYear[Year])
VAR _curModel = SELECTEDVALUE(DimModel[ModelCategory])
VAR _rankedTable = ADDCOLUMNS(FILTER(_tmpTable, [ModelCategory] &amp;lt;&amp;gt; BLANK()), "rank", 
    VAR _curTmptableYear = [Year]
    RETURN
    RANKX(FILTER(_tmpTable, [Year]=_curTmptableYear), [sentiment],,ASC,Dense))
RETURN
MAXX(FILTER(_rankedTable, [Year] = _curYear &amp;amp;&amp;amp; [ModelCategory] = _curModel), [rank])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Djerro123&lt;/P&gt;&lt;P&gt;-------------------------------&lt;/P&gt;&lt;P&gt;If this answered your question, please &lt;STRONG&gt;mark it as the Solution&lt;/STRONG&gt;. This also helps others to find what they are looking for.&lt;/P&gt;&lt;P&gt;Keep those &lt;STRONG&gt;thumbs up&lt;/STRONG&gt; coming! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 18:37:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Rank-based-on-more-tables/m-p/918232#M8957</guid>
      <dc:creator>JarroVGIT</dc:creator>
      <dc:date>2020-01-31T18:37:24Z</dc:date>
    </item>
  </channel>
</rss>

