Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

RowNo() Help

Hi,

As an example, here is a base table

Name, Category

James, Top

Ben, Top

Harry, Med

Sophie, Med

Sally, Low

How would I create a straight table, which looks like the below:

Name, Category, expr1

James, Top, 1

Ben, Top, 1

Harry, Med, 2

Sophie, Med, 2

Sally, Low, 3

To summarise, I need to build an expression which "autonumbers" on the dimension "Category"

How could I do this?

1 Solution

Accepted Solutions
er_mohit
Master II
Master II

Add Dimension Name Category in straight table and add expression

Aggr(NODISTINCT RowNo(),Category)  //label Autonumber

hope it helps

View solution in original post

13 Replies
Not applicable
Author

You can create an additonal field in the data model in order to rank your categories:

Name, Category, Rank

James, Top, 1

Ben, Top, 1

Harry, Med, 2

etc..

Other aproximation could be declaring Category field as dual.

Regards.

Not applicable
Author

Thanks for your response,

unfortunately- I can't make any changes to the data model. This must all be done inside an expression.

Not applicable
Author

Hi Wallerjc,

Here you have a sample solution only in front end.. Still, solving this issue in Script will be recomended..

Not applicable
Author

You can use either mixmatch() or wildmatch() functions

sth like : mixmatch(Category, 'Top', 'Mid', 'Low')

Fabrice

Not applicable
Author

hi

in script write this

pick(match(Category,'Top','Med','Low'),'1','2','3')  as newfield

Not applicable
Author

hi

try this

load *,

pick(match(Category,'Top','Med','Low'),'1','2','3')  as newfield

Inline [

Name, Category

James, Top

Ben, Top

Harry, Med

Sophie, Med

Sally, Low

] ;

then output like this

NameCategorynewfield
JamesTop1
BenTop1
HarryMed2
SophieMed2
SallyLow3
Not applicable
Author

hi

also try this

load *,

if(Previous(Category)=Category,peek(field),rangesum(1,peek(field))) as field

Inline [

Name, Category

James, Top

Ben, Top

Harry, Med

Sophie, Med

Sally, Low

] ;

Then output like this

NameCategoryfield
JamesTop1
BenTop1
HarryMed2
SophieMed2
SallyLow3
er_mohit
Master II
Master II

Add Dimension Name Category in straight table and add expression

Aggr(NODISTINCT RowNo(),Category)  //label Autonumber

hope it helps

Not applicable
Author

This solution works but isn't scalable at all, my actual data set has around 2,000 "Category's" do you have any further ideas? Perhaps this isn't possible... ?