+ Reply to Thread
Results 1 to 11 of 11

Dax TOPN return top N values in descending order

  1. #1
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    612

    Dax TOPN return top N values in descending order

    I've been trying to get TOPN to return the top 3 values sorted desending,

    I've tried varoius perumtions of the following, but the 'top' result is always the lowest value;

    Please Login or Register  to view this content.

    In excel ;
    Please Login or Register  to view this content.
    which I've attached, how can I get topn in dax to give the same reusult?

    The code below is what I am basing my attempts on;

    Please Login or Register  to view this content.
    RD
    Attached Files Attached Files
    Last edited by Dicken; 06-20-2023 at 08:47 AM. Reason: error

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,861

    Re: Dax topn

    Administrative Note:

    POOR THREAD TITLE

    We would very much like to help you with your query, however the thread title does not really convey what your request is about. Tell us what you are trying to do, not how you think it should be done.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    612

    Re: Dax topn

    Sorry , made a bit more descriptive

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,861

    Re: Dax TOPN return top N values in descending order

    Thank you.

  5. #5
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,428

    Re: Dax TOPN return top N values in descending order

    Please try
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    612

    Re: Dax TOPN return top N values in descending order

    This is Excel, I wanted the DAX TOPN equivalent.

    RD

  7. #7
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    612

    Re: Dax TOPN return top N values in descending order

    thanks for the suggestion, always forget about 'take', just not what I was looking for re TOPN

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Dax TOPN return top N values in descending order

    TOPN doesn't guarantee any particular order for the results. Since you are using EVALUATE you can specify an ORDER BY clause there.
    Rory

  9. #9
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    612

    Re: Dax TOPN return top N values in descending order

    So in this MS Docs,

    TOPN(<N_Value>, <Table>, <OrderBy_Expression>, [<Order>[, <OrderBy_Expression>, [<Order>]]…])

    What does the second ' order by , order ' do?
    Please Login or Register  to view this content.
    So this bring back the top 3 , not any order, but if I add the second clause,

    Please Login or Register  to view this content.
    it doesn't make any difference, so I tried using ORDER BY ;

    Please Login or Register  to view this content.
    ,

    This just returned an error? I did try a comma between DESC, ORDER and no comma, no difference?

    RD

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Dax TOPN return top N values in descending order

    It does the same as the first order by clause.

    ORDER BY belongs to EVALUATE, not to TOPN which is why you’re getting an error

  11. #11
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    612

    Re: Dax TOPN return top N values in descending order

    Thanks,
    Got that working,

    Please Login or Register  to view this content.
    RD

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. DAX TOPN concatenate
    By Dicken in forum Office 365
    Replies: 5
    Last Post: 06-12-2023, 08:55 AM
  2. DAX TOPN function
    By Dicken in forum Office 365
    Replies: 7
    Last Post: 12-02-2022, 07:02 PM
  3. Replies: 1
    Last Post: 01-09-2021, 06:14 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1