Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Narz
Partner - Contributor III
Partner - Contributor III

Qlik sense - Subtract two numeric value in script

I am trying to subtract two numeric values in script which returns me always 0. 

For Example:

JanActual - MarchActual as Actalvalue

When I try the same in Chart function I get the result.

Sum(JanActual) - Sum(MarchActual) => Gives result.

I tried converting num(JanActual) - num(MarchActual). Still result is 0. Can someone tell me what I am missing here.

Labels (1)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

This is something you need to do at chart level, not script

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

6 Replies
deepanshuSh
Creator III
Creator III

If you are trying to use it in the backend then you need to group by the data based whichever field you are trying to calculate it on. And if on front end, check using a simple table if data is actually there, and if the data is there and still error persists, then you need to share some sample data for the same. 

Trial and error is the key to get unexpected results.
Narz
Partner - Contributor III
Partner - Contributor III
Author

 

DeepanshuSh

In the back end I am trying to subtract

Please find the sample

Table1:

LOAD Code, Title, Emp_Count_Jan,  

Expected_Amount_Jan,  Original_Amount_Jan

‘Jan’ as Flag

FROM (Jan Excel)

 

Concatenate

LOAD Code, Title, Emp_Count_Feb,  

Expected_Amount_Feb,  Original_Amount_Feb

‘Feb’ as Flag

FROM (Feb Excel)

 

FinalTable

LOAD Code, Title, Emp_Count_Feb,  Flag, Expected_Amount_Jan,  Original_Amount_Jan, Expected_Amount_Feb, Original_Amount_Feb

Expected_Amount_Feb - Expected_Amount_Jan as ExpectedAmt_diff,

Original_Amount_Feb - Original_Amount_Jan as OriginalAmt_diff

Resident Table1; Drop Table Table1;

 

Front End it works. In attached highlighted is from Script and the next column front end calculation

Group by need aggregation. I am not sure how i add in mine. Thanks

vinieme12
Champion III
Champion III

Refer this blog 

https://community.qlik.com/t5/QlikView-App-Dev/Understanding-Join-Keep-and-Concatenate/td-p/328379

 

You need to Join the data so that they are on the same row based on the code and title

Concatenate will append data to the bottom of the table

Table1:

LOAD Code, Title, Emp_Count_Jan,  

Expected_Amount_Jan,  Original_Amount_Jan

‘Jan’ as Flag

FROM (Jan Excel)

 

Left Join(Table1)

LOAD Code, Title, Emp_Count_Feb,  
Expected_Amount_Feb,  Original_Amount_Feb

‘Feb’ as Flag

FROM (Feb Excel)

 

FinalTable

LOAD Code, Title, Emp_Count_Feb,  Flag, Expected_Amount_Jan,  Original_Amount_Jan, Expected_Amount_Feb, Original_Amount_Feb
Expected_Amount_Feb - Expected_Amount_Jan as ExpectedAmt_diff,
Original_Amount_Feb - Original_Amount_Jan as OriginalAmt_diff

Resident Table1; Drop Table Table1;

 

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Narz
Partner - Contributor III
Partner - Contributor III
Author

Vinieme12 

When I do a left join the Flag is always set as Jan.

Need the Flag to get Month wise employee count Thanks

vinieme12
Champion III
Champion III

This is something you need to do at chart level, not script

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Narz
Partner - Contributor III
Partner - Contributor III
Author

 Vinieme12 

 Ok. I tried and wanted to check if I am missing something in the script. 

Front end works as I have mentioned and will do the same. Thank you.