This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hello!
I have a DAX code allowing me to output a table, which I use then in other systems (PowerAutomate) to communicate via mail to users.
It needs to be ranked, however it is super annoying to see the [Rank] column in the final mail table; and I had to use a [Rank] column, as the standard date column I would simply use needs to be formatted for later consumption (otherwise it gets the universal time format in Powerautomate and it becomes difficult to read).
Anyway, question is: is there a way to pre-order the final table, so that I can eliminate the column [Rank] from it but still have it ordered by [Unit] - which I want to keep - and [Rank]? I have been playing with it way too long, hence coming to the experts 🙂
I am leaving the whole code for completeness, I have highlighted the [Rank] parts in red, and the final table I am talking about is the one after the RETURN statement.
Thank you!
Kind regards
Valeria
Solved! Go to Solution.
The argument for ORDER BY doesn't need to be in the table you're ordering, it can be a measure or an expression. Try
ORDER BY [Unit], DATEVALUE( [Prod. Date] ASC
The argument for ORDER BY doesn't need to be in the table you're ordering, it can be a measure or an expression. Try
ORDER BY [Unit], DATEVALUE( [Prod. Date] ASC
@johnt75 I love this solution! I don't know how I missed that you could use measures or expressions in ORDER BY. Thank you!!!!!
Instead of using ORDER BY use TOPN with a very large number. TOPN returns the top N rows sorted by the specified columns.
RETURN
SELECTCOLUMNS(
TOPN( 100000, -- large number to include all rows
RankedTable,
[Unit], ASC, [Rank], ASC ),
[Unit],
[Change Type],
[Delta Old/New],
[Reprint?],
[Prod. Date],
[PO],
[Change Detail],
[Old Value],
[Old Date],
[New Value],
[GMID],
[Product],
[Batch],
[Model],
[Send to SAP Date/Time]
)
I hope this helps, please give kudos and mark as solved if it does, thanks!
@wardy912 This is another interesting solution! I learned something today :-). Thank you!!!
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.