+ Reply to Thread
Results 1 to 8 of 8

DAX TOPN function

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

    DAX TOPN function

    Hi,
    Is there a way to get a distinct list of Topn nth values, or a list of all of the values that are in eg top 3,

    so in the list; 1, 2,2,2,3,3,4,5,6,7,7,7 8,8,9,10,10

    Top 3 ; 10,9, 8, and all occurrence of top ; 3 8,8,9,10,10

    I've been trying to sum the total for the top 3 values but am not getting the answer I want; I can see what it's doing by
    putting it into DAX studio, If I put
    Please Login or Register  to view this content.
    I get back a table of 5 rows of value totoal 75,, so i see what it's doing, returning position 1 and 2 and the ties for 3,
    if I change to six i get the ties for six.

    The formula I have is
    Please Login or Register  to view this content.
    I've attached a workbook with excel example of what I'd like to get back and the incorrect and correctish result, it's correct for the grand total.

    RD
    Attached Files Attached Files

  2. #2
    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,901

    Re: DAX TOPN function

    I think you mean something like this?

    Please Login or Register  to view this content.
    Rory

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

    Re: DAX TOPN function

    To retrieve result 142 please try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    but I don't understand the calculations of TOPN wanted pro item.
    Why is that for item A 121?
    Attached Files Attached Files

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

    Re: DAX TOPN function

    Re Item A giving 121, I don't know either I've been trying to see what its calculating to get that, if I fgure it out I'll let you know.


    rd

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

    Re: DAX TOPN function

    That, certainly give the correct, total, but I stll figure out what it's doing drop the item into a pivot table ,
    81, 49 , 50 42 , with even with my math's don't make 142, still thanks. One thing, when I tried your formula in DAX studio it returned an error, but worked fine in 'reality', curious, which just about sums up the function.

    rd

    NB the reason the dax studio didn't work is I forgot to add the { } to scaler, suddenly realized making tea.
    Last edited by Dicken; 12-02-2022 at 03:30 PM. Reason: Made a mistake

  6. #6
    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,901

    Re: DAX TOPN function

    Measures do the same calculation at every level. 142 is not the sum of the other numbers. It's the sum of all values matching the top 3 values overall.

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

    Re: DAX TOPN function

    I'm glad t o have helped and thanks for the feedback and rep .

  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,901

    Re: DAX TOPN function

    Quote Originally Posted by Dicken View Post
    Re Item A giving 121, I don't know either I've been trying to see what its calculating to get that, if I fgure it out I'll let you know.


    rd
    It's the top 10 rows for A. If there is a tie at the last item (as here), it includes all rows matching that item, so you get both 7 values.

+ 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. Replies: 1
    Last Post: 01-09-2021, 06:14 AM
  2. Right function, Left function, Mid function to extract values in column A
    By bjnockle in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 06-14-2020, 03:14 PM
  3. How to combine the WORKDAY function with an IF function to build a working Gantt chart.
    By roomaggoo in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 2
    Last Post: 07-07-2018, 11:54 AM
  4. COUNTUNIQUE Function in Google Sheets; Excel lacks a direct counterpart to this function?
    By PivotTablePSHomage in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-18-2018, 05:27 AM
  5. Calling function inside function. (aka nested function)
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2015, 05:58 AM
  6. Replies: 13
    Last Post: 04-08-2014, 05:46 AM
  7. Replies: 1
    Last Post: 03-21-2012, 11:22 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