Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Edyta
Contributor III
Contributor III

grand total for one field of straight table

Hello,

Could  you help me to adapt the code to get the grand total of the column Quantity?

My table looks like:

IndexItemQuantity
53535X-45
65456Y-486
43554Z-765

 

The Code I have is below. I had to myltiply the values by -1 to get the real sale.

Newone:
LOAD [Index],
[Item],
if("[Quantity]">0, "[Quantity]"*-1, "[Quantity]"*-1)
Resident sale;
Drop Table sale;

Thanks in advance.

Labels (3)
1 Solution

Accepted Solutions
sunny_talwar

For script you can do this

Newone:
LOAD [Index],
  [Item],
  if("[Quantity]">0, "[Quantity]"*-1, "[Quantity]"*-1) as Quantity
Resident sale;

Drop Table sale;

Concatenate (Newone)
LOAD Sum(Qunatity) as Quantity
Resident Newone;

View solution in original post

8 Replies
sunny_talwar

Get the grant total in the script?

Edyta
Contributor III
Contributor III
Author

yes, in script

sunny_talwar

What would the Index and Item value be for the total row?

Edyta
Contributor III
Contributor III
Author

What I need to obtain is:

IndexItemQuantity
53535X45
65456Y486
43554Z765
  1 296

I am new to Qlik Sense and not sure whether it is possible to obtain.

Regards

sunny_talwar

This is possible, but is not best practice. This is something you can very easily do it on the front end, is there a reason you want this to be done in the script?

Edyta
Contributor III
Contributor III
Author

I need it for the report to get the total sale, because I need to show the sale per product and the total sale por particular period of time.

What solution can you propose?

sunny_talwar

For script you can do this

Newone:
LOAD [Index],
  [Item],
  if("[Quantity]">0, "[Quantity]"*-1, "[Quantity]"*-1) as Quantity
Resident sale;

Drop Table sale;

Concatenate (Newone)
LOAD Sum(Qunatity) as Quantity
Resident Newone;

Edyta
Contributor III
Contributor III
Author

Thank you very much, it works!

I have worked on it since morning!