Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
This is something you need to do at chart level, not script
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.
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
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;
When I do a left join the Flag is always set as Jan.
Need the Flag to get Month wise employee count Thanks
This is something you need to do at chart level, not script
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.