<?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: Top N for Many Columns in Table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-for-Many-Columns-in-Table/m-p/3991642#M154870</link>
    <description>&lt;P&gt;Thank you for the reply and follow up. Give me some time to play with before replying or Accepting the solution. Nag me next week if I forget &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jun 2024 17:19:22 GMT</pubDate>
    <dc:creator>gigaenvy</dc:creator>
    <dc:date>2024-06-13T17:19:22Z</dc:date>
    <item>
      <title>Top N for Many Columns in Table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-for-Many-Columns-in-Table/m-p/3989320#M154645</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am very new to DAX. Actually, 1st timer and have realized I need to do something with DAX code to get Top N (10) results based on a multi column table with different choices being imported from SharePoint.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is to create a Top N (10) Table Visual for 'FAILED' values. The Patient Name can be a filter as they may have visited many times prior, but so can other slicers such as City, State, and other personal characteristics if I want to see a larger group of people in a demographic.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It should just be a simple Top N displaying in visual Highest to Lowest and no other information other than the column names as shown below.&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 asked Copilot to help, but I did't try as it seems there could be a more streamlined way. Is the below correct before I rinse and repeat for 21 different columns in the table?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1.&amp;nbsp;&amp;nbsp;Repeat this for each column you want to include in the visual.&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;Failed_LCD1 = CALCULATE(COUNTROWS(PatientCheck_InspAnswers), PatientCheck_InspAnswers[HeartO] = "Failed")&lt;/PRE&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;2.&amp;nbsp;Create a Measure for Top 10 Failed.&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;Top_10_Failed = 
VAR TopNValue = 10
VAR FailedTable = UNION(
    SELECTCOLUMNS(FILTER(PatientCheck_InspAnswers, PatientCheck_InspAnswers[HeartO] = "Failed"), "Item", "HeartO", "Count", [Failed_HeartO),
    SELECTCOLUMNS(FILTER(PatientCheck_InspAnswers, Patientheck_InspAnswers[HeartL] = "Failed"), "Item", "HeartL", "Count", [Failed_HeartL]),
    // ... repeat for each column ...
)
VAR RankedTable = ADDCOLUMNS(FailedTable, "Rank", RANKX(FailedTable, [Count],, DESC, Dense))
RETURN FILTER(RankedTable, [Rank] &amp;lt;= TopNValue)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 17:33:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-for-Many-Columns-in-Table/m-p/3989320#M154645</guid>
      <dc:creator>gigaenvy</dc:creator>
      <dc:date>2024-06-12T17:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Top N for Many Columns in Table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-for-Many-Columns-in-Table/m-p/3989970#M154728</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="306529" data-lia-user-login="gigaenvy" class="lia-mention lia-mention-user"&gt;gigaenvy&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your first syntax is logically correct, which is great!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your second syntax is a little wrong, here is the revised one:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Top_10_Failed =
VAR TopNValue = 10
VAR FailedTable = UNION(
SELECTCOLUMNS(FILTER(PatientCheck_InspAnswers, PatientCheck_InspAnswers[HeartO] = "Failed"), "Item", "HeartO", "Count", [Failed_LCD1]),
SELECTCOLUMNS(FILTER(PatientCheck_InspAnswers, PatientCheck_InspAnswers[HeartL] = "Failed"), "Item", "HeartL", "Count", [Failed_LCD2])
// Repeat for each measure/column...
)
VAR RankedTable = ADDCOLUMNS(FailedTable, "Rank", RANKX(ALL(FailedTable), [Count], , DESC, Dense))
RETURN FILTER(RankedTable, [Rank] &amp;lt;= TopNValue)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please change the underlined [Failed_HeartO) to [Failed_LCD1], and so on, change [Failed_HeartL] to [Failed_LCD2]...&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please add the ALL function to the underlined FailedTable to prevent it from possible context filtering effects.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try the modified syntax. If it does not work, I would be grateful if you could provide me with the pbix file or sample data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remember to remove sensitive data and do not log in to your account in Power BI Desktop when uploading the pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any other questions please feel free to contact me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 02:21:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-for-Many-Columns-in-Table/m-p/3989970#M154728</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-13T02:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Top N for Many Columns in Table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-for-Many-Columns-in-Table/m-p/3991642#M154870</link>
      <description>&lt;P&gt;Thank you for the reply and follow up. Give me some time to play with before replying or Accepting the solution. Nag me next week if I forget &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 17:19:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-for-Many-Columns-in-Table/m-p/3991642#M154870</guid>
      <dc:creator>gigaenvy</dc:creator>
      <dc:date>2024-06-13T17:19:22Z</dc:date>
    </item>
  </channel>
</rss>

