Forum Discussion
Count duplicate value as rank it
- 6 years ago
Hi Anonymous ,
We need to add an index column using Power Query Editor and create a calculate column to meet your requirement.
1. Create an index column.
2. Then we can create a calculate column.
Rank column = RANKX(FILTER('Table','Table'[Name]=EARLIER('Table'[Name])),'Table'[Index],,ASC,Dense)If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.
Hi Anonymous ,
I think you would be better off indexing your rows using Power Query, using the index by group pattern, you will find a couple great links here,
http://datacornering.com/how-to-create-group-index-with-power-query-or-r/
https://radacad.com/create-row-number-for-each-group-in-power-bi-using-power-query
Below please find the Power Query I used to create the index column that i think you are looking for
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WykrMTVXSUTJUitUBcvLzEGyIhBEyxxhJFYqECZIEUFEsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Name " = _t, result = _t]),
#"Removed Columns" = Table.RemoveColumns(Source,{"result"}),
#"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"Name ", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Name ", "Name"}}),
#"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "Index", 1, 1, Int64.Type),
#"Grouped Rows" = Table.Group(#"Added Index", {"Name"}, {{"Count", each _, type table [Name=nullable text, Index=number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Ranker", each Table.AddIndexColumn([Count], "Rank", 1, 1)),
#"Expanded Ranker" = Table.ExpandTableColumn(#"Added Custom", "Ranker", {"Rank"}, {"Ranker.Rank"})
in
#"Expanded Ranker"
Hope this helps,
Richard
Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!