Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
PEyzaguirre
Partner - Contributor
Partner - Contributor

Add two dimensions in one

Dear Ones, I turn to you again for help. I have a sales table, associated with a code and a referral. For example the code 20 was referred by code 300:

CodigoRefSum(Venta)
  18.272.049
20
3002.167.167
55001.334.083
1509004.594.428
1 1.035.606
9 1.174.284
500 1.977.784
900 2.971.565
300 3.017.132

 

So if I want to see the contribution of code 300 I should consider besides the sale of code 20.

CodigoSum(Monto)Monto RefA+B
 18.272.049  
202.167.167 2.167.167
51.334.083 1.334.083
1504.594.428 4.594.428
11.035.606 1.035.606
91.174.284 1.174.284
5001.977.7841.334.0833.311.867
9002.971.5654.594.4287.565.993
3003.017.1322.167.1675.184.299

 

I hope you can help me.
4 Replies
dplr-rn
Partner - Master III
Partner - Master III

Hi

Assuming that the Sum(Venta) is a number but in a different format

Master:
LOAD Codigo, 
     Ref, 
     [Sum(Venta)]
FROM
[.\Comm1521800.xlsx]
(ooxml, embedded labels, table is Sheet1);


Left join (Master)
Load
	Ref as Codigo, 
    [Sum(Venta)] as [Monto Ref]
resident Master
where IsNull(Ref)=0;

MasterFinal:
Load *,
	[Sum(Venta)]+[Monto Ref]	as [A+B]
resident Master;

drop table Master;

Output

 

Codigo Ref Sum(Venta) Monto Ref A+B 
1 1035.606  
55001334.083  
9 1174.284  
203002167.167  
1509004594.428  
300 3017.1322167.1675184.299
500 1977.7841334.0833311.867
900 2971.5654594.4287565.993
  18272.049  
PEyzaguirre
Partner - Contributor
Partner - Contributor
Author

Thanks for the reply, but the magic must be in the object and not in the script
dplr-rn
Partner - Master III
Partner - Master III

Why?
There may be a way of doing it on the object in some complicated way. But that most likely will degrade performance.
PEyzaguirre
Partner - Contributor
Partner - Contributor
Author

That is correct, but it has to be in the object since it must be sensitive to the available selections