Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
mahendragaur
Creator
Creator

Data Distribution

Hello Amigo,

I have data of different people based on weeks (refer below screenshot)-

 

NameW1W2W3W4W5
A0050300
B05602020
C0101001010
D050505050
E020106011
F01060205

and I want to distribute it in 5 category for all weeks-

and distribution should be based on below table

 

Categorymultiplication factor
10.5
20.2
30.1
40.2
50

expected output-

 

NameCategoryW1W2W3W4W5
A10025150
A2001060
A300530
A4001060
A500000
B102.5301010
B2011244
B300.5622
B4011244
B500000
C1055055
C2022022
C3011011
C4022022
C500000

that means 1st category should be multiplied by 0.5 and 2nd by 0.2 and so on...

1 Reply
el_aprendiz111
Specialist
Specialist

Hi,

2 options

1 SCRIPT

2 CHART

TMP:
LOAD * Inline
[
Name,W1,W2,W3,W4,W5
A,0,0,50,30,0
B,0,5,60,20,20
C,0,10,100,10,10
D,0,50,50,50,50
E,0,20,10,60,11
F,0,10,60,20,5
]

;



LET vNamFil = noofrows('Name');

FOR i = 1 TO NoOfRows('TMP') 

LET vTbl = FieldValue('Name', $(i)); 

FOR x = 1 to 5;
UNQUALIFY*;
DATA: 
LOAD *, $(x) AS Category
Resident TMP
Where Name = '$(vTbl)'


;

NEXT   

NEXT 


DROP TABLE TMP; 

Inner Join

Factor:

LOAD
num(Category) as Category,
Replace([multiplication factor],'.',',') As [multiplication factor]
Inline
[
Category,multiplication factor
1,0.5
2,0.2
3,0.1
4,0.2
5,0
]
;


SUMARY:
LOAD
Name AS _Name,
W1*[multiplication factor] AS _W1,
W2*[multiplication factor] AS _W2,
W3*[multiplication factor] AS _W3,
W4*[multiplication factor] AS _W4,
W5*[multiplication factor] AS _W5
Resident DATA
Order By Name asc
;

valuue.png