Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Chrvs
Contributor II
Contributor II

Creating a new column in table

Hi 

I am brand new to Qlik and I am still learning what the capabilities of Qlik are.

I got a table of n entries and I want to create a new column where each entry gets a "priority number" based on conditions of other columns. The priority columns should include every integer from 1 to n.

For example if we have a table like this:

Chrvs_1-1661246529901.png

I wish to add a new column called "Priority" like you see here:

Chrvs_0-1661246441327.png

For the particular case a 1 in priority should be given to the entry with the highest value in "Z". If more than one entry has the same value of "Z" then the lowest "X" value should determine which one is 1 and which one is 2. And when the "X" values are similar as well the priority should be determined randomly. 

Is this possible to do in Qlik and if so, can anybody help me how to go about it?

 

Thanks

Labels (1)
1 Solution

Accepted Solutions
Or
MVP
MVP

Assuming you want this done in script, perhaps something along the lines of:

Temp:
Load * INLINE [
X, Y, Z
100, 5, 9
150, 6, 10
330, 8, 5
];


Load X, Y, Z, RecNo() as Priority
Resident Temp
Order by Z desc, X, Y;

Drop Table Temp;

View solution in original post

2 Replies
Or
MVP
MVP

Assuming you want this done in script, perhaps something along the lines of:

Temp:
Load * INLINE [
X, Y, Z
100, 5, 9
150, 6, 10
330, 8, 5
];


Load X, Y, Z, RecNo() as Priority
Resident Temp
Order by Z desc, X, Y;

Drop Table Temp;

Chrvs
Contributor II
Contributor II
Author

Thanks for the answer Or.

It worked 🙂