The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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!!!
User | Count |
---|---|
15 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
24 | |
20 | |
12 | |
9 | |
7 |