<?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 Display value with highest average score in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-value-with-highest-average-score/m-p/4370297#M173494</link>
    <description>&lt;P&gt;Hi all, newbie here.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to show the "Wine Name" for the one that has the highest average score, and the 2nd highest average score.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the condition that the "Wine Name" has appeared in the dataset more than once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note : Average score is calculated using&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;wine_fact&lt;/SPAN&gt;&lt;SPAN&gt;[points]&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Link to pbix file :&amp;nbsp;&lt;BR /&gt;&lt;A href="https://drive.google.com/drive/folders/1d_6_pT5TJtg5KpRC79plvzXfako83upA?usp=sharing" target="_blank" rel="noopener"&gt;https://drive.google.com/drive/folders/1d_6_pT5TJtg5KpRC79plvzXfako83upA?usp=sharing&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Appreciate any help, much thanks!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 18 Jan 2025 18:23:21 GMT</pubDate>
    <dc:creator>holywasabi</dc:creator>
    <dc:date>2025-01-18T18:23:21Z</dc:date>
    <item>
      <title>Display value with highest average score</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-value-with-highest-average-score/m-p/4370297#M173494</link>
      <description>&lt;P&gt;Hi all, newbie here.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to show the "Wine Name" for the one that has the highest average score, and the 2nd highest average score.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the condition that the "Wine Name" has appeared in the dataset more than once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note : Average score is calculated using&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;wine_fact&lt;/SPAN&gt;&lt;SPAN&gt;[points]&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Link to pbix file :&amp;nbsp;&lt;BR /&gt;&lt;A href="https://drive.google.com/drive/folders/1d_6_pT5TJtg5KpRC79plvzXfako83upA?usp=sharing" target="_blank" rel="noopener"&gt;https://drive.google.com/drive/folders/1d_6_pT5TJtg5KpRC79plvzXfako83upA?usp=sharing&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Appreciate any help, much thanks!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2025 18:23:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-value-with-highest-average-score/m-p/4370297#M173494</guid>
      <dc:creator>holywasabi</dc:creator>
      <dc:date>2025-01-18T18:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Display value with highest average score</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-value-with-highest-average-score/m-p/4370550#M173505</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="770950" data-lia-user-login="holywasabi" class="lia-mention lia-mention-user"&gt;holywasabi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These days, I would recommend using the INDEX function to return a value with a given rank where the ranking is based on multiple values. In this case, it appears that you need &lt;STRONG&gt;Wine Name&lt;/STRONG&gt; to be ranked first based on&amp;nbsp;&lt;STRONG&gt;[score (average)]&lt;/STRONG&gt; then based on&amp;nbsp;&lt;STRONG&gt;Wine Name &lt;/STRONG&gt;itself (ascending lexicographic ordering).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is how you could write the measures. The only difference between them is the&amp;nbsp;&lt;STRONG&gt;WineRank&lt;/STRONG&gt; variable which should be set to the desired rank.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;wine name (wine score (average) top-1) = 
VAR WineRank = 1 -- Change to desired rank
VAR WineScore =
    ADDCOLUMNS (
        FILTER (
            VALUES ( wine_fact[Wine Name] ),
            CALCULATE ( COUNTROWS ( wine_fact ) ) &amp;gt; 1
        ),
        "@Score", [score (average)]
    )
VAR WineResult =
    SELECTCOLUMNS (
        INDEX (
            WineRank,
            WineScore,
            -- For equal scores, ties are broken using Wine Name (ascending lexicographic ordering)
            ORDERBY ( [@Score], DESC, wine_fact[Wine Name], ASC )
        ),
        "@WineResult", wine_fact[Wine Name]
    )
RETURN
    WineResult&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;wine name (wine score (average) top-2) = 
VAR WineRank = 2 -- Change to desired rank
VAR WineScore =
    ADDCOLUMNS (
        FILTER (
            VALUES ( wine_fact[Wine Name] ),
            CALCULATE ( COUNTROWS ( wine_fact ) ) &amp;gt; 1
        ),
        "@Score", [score (average)]
    )
VAR WineResult =
    SELECTCOLUMNS (
        INDEX (
            WineRank,
            WineScore,
            -- For equal scores, ties are broken using Wine Name (ascending lexicographic ordering)
            ORDERBY ( [@Score], DESC, wine_fact[Wine Name], ASC )
        ),
        "@WineResult", wine_fact[Wine Name]
    )
RETURN
    WineResult&lt;/LI-CODE&gt;
&lt;P&gt;Does this work for you?&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jan 2025 08:28:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-value-with-highest-average-score/m-p/4370550#M173505</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2025-01-19T08:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Display value with highest average score</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-value-with-highest-average-score/m-p/4371526#M173549</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="770950" data-lia-user-login="holywasabi" class="lia-mention lia-mention-user"&gt;holywasabi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wish you all the best.&amp;nbsp;It seems to me that OwenAuger&amp;nbsp;'s approach is the right one and gets you the desired results.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to confirm whether you have successfully resolved this issue or if you need further assistance. If OwenAuger&amp;nbsp;'s reply was helpful to you, could you consider marking it as a solution?&amp;nbsp;This will help more users who are facing the same or similar difficulties. Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yulia Xu&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 09:28:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-value-with-highest-average-score/m-p/4371526#M173549</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-20T09:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Display value with highest average score</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-value-with-highest-average-score/m-p/4379250#M173843</link>
      <description>&lt;P&gt;Thank you so so much!&lt;/P&gt;&lt;P&gt;That is such an elegant solution, works as I had intended, and I learned something new.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Thousand apologies for the late reply, was totally flooded with work (this is a side project).&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":persevering_face:"&gt;😣&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 07:30:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-value-with-highest-average-score/m-p/4379250#M173843</guid>
      <dc:creator>holywasabi</dc:creator>
      <dc:date>2025-01-24T07:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Display value with highest average score</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-value-with-highest-average-score/m-p/4379254#M173844</link>
      <description>&lt;P&gt;Thank you for offering more assistance, Yulia&amp;nbsp;&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;It works like a charm&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":sparkles:"&gt;✨&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 07:32:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-value-with-highest-average-score/m-p/4379254#M173844</guid>
      <dc:creator>holywasabi</dc:creator>
      <dc:date>2025-01-24T07:32:44Z</dc:date>
    </item>
  </channel>
</rss>

