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: 
prabir_c
Partner - Creator
Partner - Creator

Calculated measure issue in Script

Dear Members,

I am facing a issue while concat two tables. Example, Below scenario-

Suppose, I have a details table like below (Details_Data.xlsx)- 

Site_codeDateIcodeSaleTax
101-01-2021A0011000 
102-01-2021A0022000 
103-01-2021A0033000 
104-01-2021A0044000 
105-01-2021A0055000 
201-01-2021A0011000200
202-01-2021A0022000400
203-01-2021A0033000300
301-01-2021A0011000200

and in Another Table (Details_Data_Tax.xlsx)I have only Tax related to Site_code=1

Site_codeDateIcodeTax
101-01-2021A001100
102-01-2021A002200
103-01-2021A003300
104-01-2021A004200
105-01-2021A005100

Now, I have merged two table in script :

Detail_Data:

LOAD Site_code as %_Site_Code,
Date as %_DATE,
Icode as %_ICODE,
Sale as #_SALE,
Tax as #_TAX
FROM
Detail_Data.xlsx
(ooxml, embedded labels, table is Sheet1);

Concatenate

LOAD Site_code as %_Site_Code,
Date as %_DATE,
Icode as %_ICODE,
Tax as #_TAX
FROM
Detail_Data_TAX.xlsx
(ooxml, embedded labels, table is Sheet1);

Final:
Load *,
#_SALE - #_TAX as #_TAXABLE
Resident Detail_Data;
DROP Table Detail_Data;

in front End, when I am manually calculating Sale- tax it is working, but in #_Taxable measure data is 0 for Site code=1

prabir_c_0-1619518087179.png

Please help! What I am missing?

 

1 Solution

Accepted Solutions
MayilVahanan

Hi @prabir_c 

Try like below

MapTax:
Mapping
LOAD Site_code&'-'& Date&'-'& Icode as %_Key,
Tax as #_TAX
FROM
Detail_Data_TAX.xlsx
(ooxml, embedded labels, table is Sheet1);

Detail_Data:

LOAD Site_code as %_Site_Code,
Date as %_DATE,
Icode as %_ICODE,
Sale as #_SALE,
ApplyMap('MapTax',Site_code&'-'& Date&'-'& Icode, Tax) as #_TAX
FROM
Detail_Data.xlsx
(ooxml, embedded labels, table is Sheet1);

 

Final:
Load *,
#_SALE - #_TAX as #_TAXABLE
Resident Detail_Data;
DROP Table Detail_Data;

O/p in table viewer:

MayilVahanan_0-1620180248958.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

4 Replies
MayilVahanan

HI @prabir_c 

Concatenate will append the second table to first table. It doesn't join. 
If we see the table viewer, we can understand the result..

MayilVahanan_0-1619519728670.png

For your case, you can do mapping the second table into first and do the calculation for Taxable. 
Or in front end, you can achieve the result.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
prabir_c
Partner - Creator
Partner - Creator
Author

Hi MayilVahanan,

Mapping the second table into first means? Using mapping load?

Please clarify.

prabir_c
Partner - Creator
Partner - Creator
Author

Hi MayilVahanan,

I have to merge both table's tax amount together. And I don't want to change manually in front end for each and every report expression as =Sale- Tax for taxable amt. Because I have already used Taxable amt which contains the calculated measure value for Taxable (other than site code 1)

So, I have to do the changes in script only.

What to do for showing the tax and sale of site code=1 in a single line? Please help!

MayilVahanan

Hi @prabir_c 

Try like below

MapTax:
Mapping
LOAD Site_code&'-'& Date&'-'& Icode as %_Key,
Tax as #_TAX
FROM
Detail_Data_TAX.xlsx
(ooxml, embedded labels, table is Sheet1);

Detail_Data:

LOAD Site_code as %_Site_Code,
Date as %_DATE,
Icode as %_ICODE,
Sale as #_SALE,
ApplyMap('MapTax',Site_code&'-'& Date&'-'& Icode, Tax) as #_TAX
FROM
Detail_Data.xlsx
(ooxml, embedded labels, table is Sheet1);

 

Final:
Load *,
#_SALE - #_TAX as #_TAXABLE
Resident Detail_Data;
DROP Table Detail_Data;

O/p in table viewer:

MayilVahanan_0-1620180248958.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.