Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Not applicable

Assign incremental values based on ID

Hi,

I have got the following script :

[Product Category]:
   LOAD

ID                                                                                      as        ID
,
If(ID <> Previous(ID), category_name, '') as    category_name
,
If(ID <>Previous(ID), Order, Order+1)    as    Order     

,[Product Category]                                                    as         Value


;
LOAD Distinct
'$(vOrder)'                   
as Order
,'$(
vcategory_name)'           as category_name                                  
ID       
,
[Product Category]           as [Product Category]
Resident
TmpProducts

Order By
ID

,[Product Category];

And that produces the following table, ex:

Product Category

Order

Value

Clothes

70

Shirt

71

Jeans

71

Long Sleeve shit

71

Short

71

Skirt

71

Shoes

71

Babies Shoes

But I am trying to achieve this:

Product Category

Order

Value

Clothes

70

Shirt

72

Jeans

73

Long Sleeve shit

74

Short

75

Skirt

76

Shoes

77

Babies Shoes

For each ID, the order should start at 70 (already in variable) and increment until it reaches the number of values by that ID.

Could you help me please achieve this goal. I was think of Loop, but I want to use it as last resource because of performance.

Thank you very much.

1 Solution

Accepted Solutions
Highlighted
MVP & Luminary
MVP & Luminary

Re: Assign incremental values based on ID

Try this:


,If(ID <>Previous(ID), Order, peek(Order)+1)    as    Order 


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Highlighted
MVP & Luminary
MVP & Luminary

Re: Assign incremental values based on ID

Try this:


,If(ID <>Previous(ID), Order, peek(Order)+1)    as    Order 


talk is cheap, supply exceeds demand

View solution in original post

Highlighted
Not applicable

Re: Assign incremental values based on ID

Thanks for your help.... You were a time saver (: