Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi,
I have created a summarized table similar to the below table.
And the expected output is as shown below
I have to first sort the summarized table in descending order of Date and consider the top N rows from every individual row excluding blanks. I tried but couldn't get the expected result.
Could someone please help me in achieving this?
Hi @amitchandak,
Please find data in the below link
https://docs.google.com/spreadsheets/d/1sHk06ih0X4UEbseVoWz0Fwzg8h5TxR4g-I443VEBgyk/edit?usp=sharing
I was looking for a query in DAX.
The expected output would look like
Thanks
@Anonymous
Here is a solution based on your initial table and N = 2. Place the following M code in a blank query to see the steps.
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NYzLDQAgCEN36dmLH1BnIey/hoCQECgPWhH0gQary392aJMQfmD6dATduVlNlzMo+eMqeyyVwcvaSRcVzUjHDNUH", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", Int64.Type}, {"Column3", Int64.Type}, {"Column4", Int64.Type}, {"Date", Int64.Type}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Date", Order.Ascending}}),
    N_ = 2, //Number of items to be extracted (Top N)
    col1_ = List.FirstN(List.Select(#"Sorted Rows"[Column1], each _<> null), N_), 
    col2_ = List.FirstN(List.Select(#"Sorted Rows"[Column2], each _<> null), N_),
    col3_ = List.FirstN(List.Select(#"Sorted Rows"[Column3], each _<> null), N_),
    col4_ = List.FirstN(List.Select(#"Sorted Rows"[Column4], each _<> null), N_),
    res_ = Table.FromColumns({col1_, col2_, col3_, col4_})
in
    res_
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Hi @AlB ,
Thanks for your quick response.
N here is 300 and please find below the link for the data.
https://docs.google.com/spreadsheets/d/1sHk06ih0X4UEbseVoWz0Fwzg8h5TxR4g-I443VEBgyk/edit?usp=sharing
For every individual column, I need to consider the top 300 order by date descending.
Thanks
Hi @Anonymous
Where is the date to sort by?
N is what number?
Can you share the original table in text-tabular format rather than with a screen cap, so that its contents can be copied?
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
            | User | Count | 
|---|---|
| 8 | |
| 5 | |
| 5 | |
| 4 | |
| 3 | 
| User | Count | 
|---|---|
| 24 | |
| 11 | |
| 10 | |
| 9 | |
| 8 |