Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Minseok
New Member

I have a question about the Power Querym function.

Hello, everyone.

I have a question about how to use PowerQuery functions.

I want to give a rank as shown below.

How should I configure the function?

 

Minseok_0-1707282623606.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Minseok ,

Please put all of this M function into Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ30jcyMDJW0lHKLc7OzFWK1YlWMtU3xhQEqoMrRVJogC5mCFRljC5orm9oBhfLBQnGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [reg_date = _t, member_id = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"reg_date", type date}, {"member_id", type text}}),
    #"GroupedRows" = Table.Group(#"Changed Type", {"member_id"}, {{"AllData", each _ ,type table}}),
    #"SortedIndexedRows" = Table.TransformColumns(#"GroupedRows", {"AllData", (table) =>
          let 
              SortedTable = Table.Sort(table, {{"reg_date", Order.Descending}}),
              IndexedTable = 
                  Table.AddIndexColumn(SortedTable, "RankOrder", 1, 1, Int64.Type)
                  in 
                      IndexedTable
            }),
    #"ExpandedTable" = 
    Table.ExpandTableColumn(#"SortedIndexedRows", "AllData", {"reg_date", "member_id", "RankOrder"}, {"reg_date", "member_id1", "RankOrder"}),
    #"Removed Columns" = Table.RemoveColumns(ExpandedTable,{"member_id1"})
in
    #"Removed Columns"

The final output is as follow:

vjunyantmsft_0-1707372726607.png

But if you need to implement sorting different ids separately, I suggest it might be more convenient to use DAX.

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Minseok ,

Please put all of this M function into Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ30jcyMDJW0lHKLc7OzFWK1YlWMtU3xhQEqoMrRVJogC5mCFRljC5orm9oBhfLBQnGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [reg_date = _t, member_id = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"reg_date", type date}, {"member_id", type text}}),
    #"GroupedRows" = Table.Group(#"Changed Type", {"member_id"}, {{"AllData", each _ ,type table}}),
    #"SortedIndexedRows" = Table.TransformColumns(#"GroupedRows", {"AllData", (table) =>
          let 
              SortedTable = Table.Sort(table, {{"reg_date", Order.Descending}}),
              IndexedTable = 
                  Table.AddIndexColumn(SortedTable, "RankOrder", 1, 1, Int64.Type)
                  in 
                      IndexedTable
            }),
    #"ExpandedTable" = 
    Table.ExpandTableColumn(#"SortedIndexedRows", "AllData", {"reg_date", "member_id", "RankOrder"}, {"reg_date", "member_id1", "RankOrder"}),
    #"Removed Columns" = Table.RemoveColumns(ExpandedTable,{"member_id1"})
in
    #"Removed Columns"

The final output is as follow:

vjunyantmsft_0-1707372726607.png

But if you need to implement sorting different ids separately, I suggest it might be more convenient to use DAX.

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mussaenda
Super User
Super User

How is the logic behind the Rank?

the 3rd row member  on the right table does not have any same name but it ranks together with kim member 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.