Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Dear friend
How can i count a duplicate value and rank it as 1,2,3,... in the other column with DAX
Name | new column |
jame | 1 |
jon | 1 |
jame | 2 |
jame | 3 |
jon | 2 |
jame | 4 |
jon | 3 |
Solved! Go to Solution.
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 ,
How about the result after you follow the suggestions mentioned in my original post?
Could you please provide more details or expected result about it If it doesn't meet your requirement?
If you've fixed the issue on your own please kindly share your solution. If the above posts help, please kindly mark it as a solution to help others find it more quickly.
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.
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!
Proud to be a Super User!
are you trying to remove the duplicates and maintain the rank??
you better off to create a new table using name as a distinct
name = distinct(tablename[name])
then use the rank funciton with tie breakers
@Anonymous - Not entirely sure I understand.
https://community.powerbi.com/t5/Quick-Measures-Gallery/To-Bleep-with-RANKX/m-p/1042520#M452
Also this because it handles dupes
https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Mythical-DAX-Index/td-p/1093214
@Anonymous m refer how to use tiebreaker in rank
https://databear.com/how-to-use-the-dax-rankx-function-in-power-bi/
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
92 | |
83 | |
71 | |
49 |
User | Count |
---|---|
143 | |
120 | |
110 | |
60 | |
57 |