This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
Hi folks,
I need help.
I need to sort each dotted rectangle as ascending by the "DATA" column for the same value columns: "RAZÃO", "COD_FORNE", "REFER_PRODUTO" and add a new INDICE (INDEX) column like this:
Its possible in M (preferably) or DAX?
Thanks for any help.
Solved! Go to Solution.
Hi @credencial
Create a blank query and open its Advanced Editor. Then paste below codes to replace all codes in Advanced editor to see the steps.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMjAwVtJRcgRiCzMQK9DQSClWByplglvKFL8uJ7iUpaUlQsoMt5Q5bimYXcZmpuh2WeCWssQtZYIpFQsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DATA = _t, CODE = _t, REFER = _t, NAME = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"DATA", Int64.Type}, {"CODE", type text}, {"REFER", Int64.Type}, {"NAME", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"CODE", "REFER", "NAME"}, {{"All", each _, type table [DATA=nullable number, CODE=nullable text, REFER=nullable number, NAME=nullable text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([All], "Index", 0, 1, Int64.Type)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"DATA", "CODE", "REFER", "NAME", "Index"}, {"DATA", "CODE", "REFER", "NAME", "Index"})
in
#"Expanded Custom"
Attach pbix file for your reference.
Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
Hi @credencial
Create a blank query and open its Advanced Editor. Then paste below codes to replace all codes in Advanced editor to see the steps.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMjAwVtJRcgRiCzMQK9DQSClWByplglvKFL8uJ7iUpaUlQsoMt5Q5bimYXcZmpuh2WeCWssQtZYIpFQsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DATA = _t, CODE = _t, REFER = _t, NAME = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"DATA", Int64.Type}, {"CODE", type text}, {"REFER", Int64.Type}, {"NAME", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"CODE", "REFER", "NAME"}, {{"All", each _, type table [DATA=nullable number, CODE=nullable text, REFER=nullable number, NAME=nullable text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([All], "Index", 0, 1, Int64.Type)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"DATA", "CODE", "REFER", "NAME", "Index"}, {"DATA", "CODE", "REFER", "NAME", "Index"})
in
#"Expanded Custom"
Attach pbix file for your reference.
Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
Easy job with PQ. First, group the table by the 3 columns; then add index to each grouped table.
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Tanks for your reply @CNENFRNL.
Sorry, I couldn't see your solution. Can be more specific?
The columns are already grouped, they should only be sorted by the "DATE" column, but in sections as shown in the dotted line.
Check out the April 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.