<?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: TopN based on Measure instead of Column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TopN-based-on-Measure-instead-of-Column/m-p/1028921#M13458</link>
    <description>&lt;P&gt;Could you use ADDCOLUMNS to add your TOPN column and then take the MIN or MAX of it?&lt;/P&gt;</description>
    <pubDate>Thu, 16 Apr 2020 04:06:52 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2020-04-16T04:06:52Z</dc:date>
    <item>
      <title>TopN based on Measure instead of Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TopN-based-on-Measure-instead-of-Column/m-p/1028599#M13452</link>
      <description>&lt;P&gt;Hi everyone, I am struggling with the TopN function and I hope you can help me out.&lt;/P&gt;&lt;P&gt;Data: event registration data, with calculated columns for CY (current year) and LY (Last year). I also created a measure to show the count difference between them, “CY-LY Reg Diff”&lt;/P&gt;&lt;P&gt;Goal: create a card that displays the region and store type with the largest deficits year-on-year (smallest value for “CY-LY Diff” measure)&lt;/P&gt;&lt;P&gt;Challenge: I have tried this formula, but it gives me “blank” as a region.&lt;/P&gt;&lt;P&gt;Largest Deficit Region = CALCULATE(SELECTEDVALUE('Sample Data'[Region]),TOPN(1,'Sample Data',[CY - LY Reg Diff],ASC))&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;Year&lt;/TD&gt;&lt;TD&gt;Store Type&lt;/TD&gt;&lt;TD&gt;Region&lt;/TD&gt;&lt;TD&gt;Registered&lt;/TD&gt;&lt;TD&gt;Last year&lt;/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Year 2&lt;/TD&gt;&lt;TD&gt;Store Type C&lt;/TD&gt;&lt;TD&gt;West&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Year 2&lt;/TD&gt;&lt;TD&gt;Store Type B&lt;/TD&gt;&lt;TD&gt;Midwest&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Year 2&lt;/TD&gt;&lt;TD&gt;Store Type B&lt;/TD&gt;&lt;TD&gt;South&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Year 2&lt;/TD&gt;&lt;TD&gt;Store Type C&lt;/TD&gt;&lt;TD&gt;Midwest&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help or tips would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 23:32:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TopN-based-on-Measure-instead-of-Column/m-p/1028599#M13452</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-15T23:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: TopN based on Measure instead of Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TopN-based-on-Measure-instead-of-Column/m-p/1028921#M13458</link>
      <description>&lt;P&gt;Could you use ADDCOLUMNS to add your TOPN column and then take the MIN or MAX of it?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 04:06:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TopN-based-on-Measure-instead-of-Column/m-p/1028921#M13458</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-04-16T04:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: TopN based on Measure instead of Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TopN-based-on-Measure-instead-of-Column/m-p/1031217#M13540</link>
      <description>&lt;P&gt;Hi, I must be doing something wrong here. I added ADDCOLUMNS to the expression, but now it looks like it's using it as multiple columns- I thought that I only added one. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;= CALCULATE( SELECTEDVALUE('Sample Data'[Region]), ADDCOLUMNS('Sample Data',"Top N",TOPN(1,'Sample Data',[CY - LY Reg Diff],ASC)))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Error message: "The expression referrs to multiple columns. Multiple columns cannot be converted to a scalar value."&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I must be missing a step or three.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 17 Apr 2020 01:48:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TopN-based-on-Measure-instead-of-Column/m-p/1031217#M13540</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-17T01:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: TopN based on Measure instead of Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TopN-based-on-Measure-instead-of-Column/m-p/1034983#M13747</link>
      <description>&lt;P&gt;This piece of code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Largest Deficit Region = 
CALCULATE(
    SELECTEDVALUE('Sample Data'[Region]),
    TOPN(1,
         'Sample Data',
         [CY - LY Reg Diff],
         ASC
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;returns BLANK because SELECTEDVALUE returns BLANK when there is more than 1 region returned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change the expression under CALCULATE to show the number of regions - distinctcount( 'sample data'[region] ) - and you'll see it's not 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please read this:&amp;nbsp;&lt;A href="https://dax.guide/topn/" target="_blank"&gt;https://dax.guide/topn/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 21:06:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TopN-based-on-Measure-instead-of-Column/m-p/1034983#M13747</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-19T21:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: TopN based on Measure instead of Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TopN-based-on-Measure-instead-of-Column/m-p/1039642#M13900</link>
      <description>&lt;P&gt;Thank you- I was actually able to get it to work!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 15:19:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TopN-based-on-Measure-instead-of-Column/m-p/1039642#M13900</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-21T15:19:04Z</dc:date>
    </item>
  </channel>
</rss>

