Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
reporting_neu
Creator III
Creator III

Rank by dimension - need positions

Hi,

I have several dimensions and no Expression. I need to assign position numbers for each different dimension, but I don't know how. 

This is what the data looks like:

BNumber RMNo
5080000 101
5080000 102
5080000 106
5080040 367
5080040 375

 

This is what it should look like:

BNumber RMNo Pos
5080000 101 1
5080000 102 2
5080000 106 3
5080040 367 1
5080040 375 2

 

Can you help me please?

Labels (4)
1 Solution

Accepted Solutions
reporting_neu
Creator III
Creator III
Author

Thank you for your answer. Unfortunately the same result as before.

Qlik does differentiate BNumber and RMNo but if there are additional different parts (post before), they will still receive the same rank.

 

But if find the sulution in expression:

=AGGR(Rank(BNumber &'-'& RMNo &'-'& Part),BNumber, Part)

 

View solution in original post

8 Replies
Clement15
Partner - Specialist
Partner - Specialist

Hello,

This should meet your need:

TEST:
load *
Inline [
BNumber, RMNo
5080000 ,101
5080000 ,102
5080000 ,106
5080040 ,367
5080040 ,375
];

NoConcatenate

TEST2:
load
*,
IF(ROWNO()=1,1,if(BNumber=Previous(BNumber),PEEK('Rank',-1)+1,1)) AS Rank
Resident TEST
Order By BNumber,RMNo;

Drop table TEST;

 

sbaro_bd
Creator III
Creator III

Hello @reporting_neu ,

If you don't want to make change son your script, you can use the Rank() function with some constraints (take a look on the attached file).

I only recommand this solution if you don't plan to use the "Pos" dimension in others calculations. Otherwise, @Clement15 is the best way.

Regards.

reporting_neu
Creator III
Creator III
Author

Vielen Dank für Ihre Arbeit und Unterstützung.

@Clement15 

Ich habe die Funktion „RowNo“ im Skript ausprobiert. Allerdings bekomme ich beim ersten Eintrag nur eine 1 und danach Null-Werte.

2024-12-20 14_28_19-G1 (in Bearbeitung)(1) - Mein neues Arbeitsblatt _ Arbeitsblatt - Qlik Sense.png

@sbaro_bd 

Ich weiß nicht, ob es an der Anzahl der Dimensionen liegt. Wenn ich nur die beiden Dimensionen "BNumber" und "RMNo" verwende, funktioniert die Funktion "Rank".

Wenn ich es jedoch in meiner Tabelle verwende, die viele Dimensionen hat, erhalte ich überall eine 1.

Für meine Zwecke würde die Rank-Funktion ausreichen.

Clement15
Partner - Specialist
Partner - Specialist

Hello,

Can you share your script with me?

sbaro_bd
Creator III
Creator III

Hello @reporting_neu ,

I see this on the community : https://community.qlik.com/t5/QlikView-App-Dev/Rank-within-a-specific-dimension-when-you-have-multip...

So, try the expression like this and let us know if it works :

AGGR(Rank(RMNo),BNumber,RMNo)

Regards.

reporting_neu
Creator III
Creator III
Author

@Clement15

Should be your script exactly:

G1:
Load
*,
IF(ROWNO()=1,1,if(BNumber=Previous(BNumber),PEEK('Rank',-1)+1,1)) AS Rank
Resident TMP_G1
Order By BNumber,RMNo;

Drop Table TMP_G1;

 

@sbaro_bd 

That looks better.

I also have different parts in the respective rows. Can I insert the data field "Parts" somewhere else? Qlik now distinguishes between BNumber and RMNo but not Part yet. If that works, I have everything I need.

2024-12-20 16_02_07-Clipboard.png

 

Qrishna
Master
Master

Simple one line solution:

AutoNumber(BNumber&'-'&RMNo,BNumber) as Rank

Add this in your table script;

 

Data:
LOAD BNumber,
RMNo,
AutoNumber(BNumber&'-'&RMNo,BNumber) as Rank
FROM
[https://community.qlik.com/t5/New-to-Qlik-Analytics/Rank-by-dimension-need-positions/td-p/2498915]
(html, codepage is 1252, embedded labels, table is @1);

2498915 - Rank by dimension - need positions (1).PNG

reporting_neu
Creator III
Creator III
Author

Thank you for your answer. Unfortunately the same result as before.

Qlik does differentiate BNumber and RMNo but if there are additional different parts (post before), they will still receive the same rank.

 

But if find the sulution in expression:

=AGGR(Rank(BNumber &'-'& RMNo &'-'& Part),BNumber, Part)