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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
sudhav
Helper V
Helper V

Need partition in ranking in power query editor

Hi Team,

I have a CTE in my sql which is giving ranking in a table and below is the code

 

select *, rank() over(partition by Empstatus,Emprole,Empdept order by empid) as Empid_Rank from EmployeeTable

 

now my requirement is, i wanted to create same ranking column in power query editor not in DAX.

can someone lookinto it and help me.

TIA

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Insert this step where #"Changed Type" needs to be replaced with your previous step

= Table.Combine(Table.Group(#"Changed Type", {"Empstatus", "Emprole", "Empdept"}, {{"All", each Table.AddRankColumn(_, "Empid_Rank", {"Empid"}, [RankKind = RankKind.Competition])}})[All])

 Code in action here

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLMS0wuySxLBTJ9E/MS01OLgCyPIKVYnWglI1R5x+LizOKSxLwSIDs4MSe1GKzIGFVRQFF+elFibi6yOSYgzZi2IMwwxW0R1AgzZCNQ7ECYYk7AOxbEeMeSsHcMDXBZhDDG0JCglwyNiPCToTH2sIOZYUKMnwxNcdoEM8cMuzVIZpgjq8DmHQtivGNJSFEsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Empid = _t, Empstatus = _t, Emprole = _t, Empdept = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Empid", Int64.Type}, {"Empstatus", type text}, {"Emprole", type text}, {"Empdept", type text}}),
    #"Grouped Rows" = Table.Combine(Table.Group(#"Changed Type", {"Empstatus", "Emprole", "Empdept"}, {{"All", each Table.AddRankColumn(_, "Empid_Rank", {"Empid"}, [RankKind = RankKind.Competition])}})[All])
in
    #"Grouped Rows"

View solution in original post

2 REPLIES 2
Vijay_A_Verma
Super User
Super User

Insert this step where #"Changed Type" needs to be replaced with your previous step

= Table.Combine(Table.Group(#"Changed Type", {"Empstatus", "Emprole", "Empdept"}, {{"All", each Table.AddRankColumn(_, "Empid_Rank", {"Empid"}, [RankKind = RankKind.Competition])}})[All])

 Code in action here

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLMS0wuySxLBTJ9E/MS01OLgCyPIKVYnWglI1R5x+LizOKSxLwSIDs4MSe1GKzIGFVRQFF+elFibi6yOSYgzZi2IMwwxW0R1AgzZCNQ7ECYYk7AOxbEeMeSsHcMDXBZhDDG0JCglwyNiPCToTH2sIOZYUKMnwxNcdoEM8cMuzVIZpgjq8DmHQtivGNJSFEsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Empid = _t, Empstatus = _t, Emprole = _t, Empdept = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Empid", Int64.Type}, {"Empstatus", type text}, {"Emprole", type text}, {"Empdept", type text}}),
    #"Grouped Rows" = Table.Combine(Table.Group(#"Changed Type", {"Empstatus", "Emprole", "Empdept"}, {{"All", each Table.AddRankColumn(_, "Empid_Rank", {"Empid"}, [RankKind = RankKind.Competition])}})[All])
in
    #"Grouped Rows"

Vijay......you are awesome man. thank you sooooooooooooooo much.. you made my day simple and happy. you saved me man. take a bow.

👏🙌

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors