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

distribute the field values in different rows

Hi experts!

I need your help in data structuring. I have a table in that total Assortment Qty is given just in one row of SKUStore Key. I want to evenly distribute it in other rows if items are already allocated. Please find the current and to be tables below. Could you help me in achieving to be data table from current model.

      

Current Data Model
CartonNumberSkuStoreAssortment QtyAssortment Qty to DisplayAllocated QtyUnallocated Qty
839R60582220
840R6058020
566R16942220
567R1694020
570R276694040
571R276694040
2766944422

      

Proposed Data Model
CartonNumberSkuStoreAssortment QtyAssortment Qty to DisplayAllocated QtyUnallocated Qty
839R60581210
840R60581210
566R16941210
567R16941210
570R2766941410
571R2766941410
2766942402
Attached is the spread sheet.

Thanks!

1 Solution

Accepted Solutions
sunny_talwar

Application attached:

View solution in original post

2 Replies
sunny_talwar

Try this script:

Table:

LOAD CartonNumberKey,

    SkuStoreKey,

    [Assortment Qty],

    [Assortment Qty to Display],

    [Allocated Qty],

    [Unallocated Qty]

FROM

Community_165549.xlsx

(ooxml, embedded labels, table is Sheet2);

Join(Table)

LOAD SkuStoreKey,

  Count(SkuStoreKey) as Count

Resident Table

Group By SkuStoreKey;

Table1:

NoConcatenate

LOAD CartonNumberKey,

    SkuStoreKey,

    [Assortment Qty to Display],

    [Unallocated Qty],

    If([Allocated Qty] = 0, 1, [Allocated Qty] - Count + 1) as [Allocated Qty],

  If([Assortment Qty] = 0, 1, [Assortment Qty] - Count + 1) as [Assortment Qty]

Resident Table

Order By SkuStoreKey, [Assortment Qty] desc;

DROP Table Table;


Output:


Capture.PNG

sunny_talwar

Application attached: