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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
ericdelaqua
Creator
Creator

In table calculations

Hello ,

I need some ideas on how to achieve the final table below giving the first 2 tables. I have a subcategory table and a second table to categories and how they values should be calculated. I am trying to achieve a single flat table containing all the categories as shown on the 3rd table below.

TABLE 1:

Sub-categoryValue
alpha12
betta34
zebra-54
echo65
romeo82
sam-1

 

TABLE  2:

Categoryvalue
laptop alpha-echo
BuldingZebra + Laptop-(sam)

 

Expected Output:

ListingValue
alpha12
betta34
zebra-54
echo65
romeo82
sam-1
laptop -53
Bulding30

 

thanks You

Labels (1)
1 Reply
avkeep01
Partner - Specialist
Partner - Specialist

Hi @ericdelaqua

You could try to add the table 2 to table 1 in the script. 

CONCATENATE (Table1) LOAD 
Category AS [Sub-category],
value AS Value
FROM Table2; 

In case the values aren't numbers in table 2 you can use this: 

CONCATENATE (Table1) LOAD 
'Laptop' AS [Sub-category],
SUM(IF([Sub-category],'alpha',Value,-1*Value)) AS Value
RESIDENT Table1
WHERE MATCH([Sub-category],'alpha','echo');

CONCATENATE (Table1) LOAD 
'Bulding' AS [Sub-category],
SUM(IF([Sub-category],'sam',Value,-1*Value)) AS Value
RESIDENT Table1
WHERE MATCH([Sub-category],'zebra','Laptop','sam');