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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Paulshap
Frequent Visitor

Rank the duplicates values

Hi community,
have the next issue. I have several values I have to rank.

Paulshap_0-1611134152258.png 

The problem is that  ranks function assign the same rank to each row and there is no any identifier to break the tie. I can't create index in Powerquery as this is calculated table. I tried to generate index via GENERATESERIES in var and return this index, but it displayes the error.

http://prntscr.com/x9zipf 

 

The formula is below

Column 2 =
var gen=GENERATESERIES(1,COUNTROWS(Table),1)
return
SELECTCOLUMNS(gen,"index",[Value])
Does anybody have the same issue and how did you solve this problem?
Thanks in advance.
1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @Paulshap 

You could create a new calculated table:

 

New table =
GENERATE (
    DISTINCT ( Table1 ),
    GENERATESERIES ( 1, CALCULATE ( COUNT ( Table1[sale_contract_id] ) ) )
)

 

Otherwise perhaps you can create the equivalent of the calculated table in PQ and add an index afterwards.

I don't think it is possible to add a column like that directly in DAX (witout creating a new table) since there is nothing to differentiate the duplicates. In any case, what is the point of this? What are you trying to do, ultimately? Most likely it can be done without that column, since it doesn't seem to add any information.

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

View solution in original post

7 REPLIES 7
AlB
Super User
Super User

Hi @Paulshap 

You could create a new calculated table:

 

New table =
GENERATE (
    DISTINCT ( Table1 ),
    GENERATESERIES ( 1, CALCULATE ( COUNT ( Table1[sale_contract_id] ) ) )
)

 

Otherwise perhaps you can create the equivalent of the calculated table in PQ and add an index afterwards.

I don't think it is possible to add a column like that directly in DAX (witout creating a new table) since there is nothing to differentiate the duplicates. In any case, what is the point of this? What are you trying to do, ultimately? Most likely it can be done without that column, since it doesn't seem to add any information.

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Paulshap
Frequent Visitor

@AlB thanks a lot. It works!😁 Regarding the aim - I had the parent table with unique agreement where it was displayed period of agreement( e.g. 3 months ),amount by agreement and % by this amount. I have to show the % proportionately the period (3 mon) with displaying date in  frame of start date and end date of agreement. I multiplied the agreement and need some index to increment the dates in frame  of agreement. The final result should look like http://prntscr.com/xagiki

Anonymous
Not applicable

Hello @Paulshap ,
You can add the index column in the calculated table calculation instead of creating a column.

VAR __Count = COUNTROWS('Table 1')
VAR __Table =
GENERATESERIES(1,__Count,1)
RETURN
__Table

Hi, thanks for your solution, but I have to get single column with index, not total table. Your solution return total table with index.

Anonymous
Not applicable

Hello @Paulshap ,
As you have said the table in the image is a calculated table.
Add another column of index column by doing the calculation in that table calculation. I hope you're getting my point.

Hi @Anonymous, if you mean your formula, it give the result of total table, not single column. Thanks.

Anonymous
Not applicable

Hello @Paulshap , 
Can you share your sample data or file after removing the sensitive data?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.