Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Husky_Bab12
Contributor
Contributor

Error on Set Analysis

I need to calculate the sum of weights for the parts.

I do have quantity for all the parts already.

I  need to calculate the same for the weights.

Variables and expressions  I used so far,

To calculate the sum of quantity ,  vCoveredQty  =sum({<[Production Status]={"1"}>} Quantity)

To calculate the sum of weight, 

vCoveredQty = (($(vCoveredQty)*(partPieceWeight))+((($(vCoveredQty)*            (shippingUnitTareWeight))/packageQuantity))*0.453592)


I can able to calculate the sum of weight for the individual parts , but when i try to calculate that for the entire parts.

I'm receiving an error, Error in Expression: Sum takes 1 Parameter?

Can someone help with this issue?

Labels (1)
1 Solution

Accepted Solutions
Digvijay_Singh

It won't work because you got your expression like this - Sum(Sum()), this is not permitted. But I see you got one new condition for Days, why don't you add that as well in your variable. It will have same effect.

Also your set expression syntax near 'Days' doesn't look right, not sure if its a date field.

={<[Days]={">=$(vStart) <=$(vEnd)"}>} 

You should check at the bottom of expression editor, and see how set conditions are showing result, and keep improving it based on your needs.

vCoveredQty1  =sum({<[Production Status]={1},[Days]={">=$(vStart) <=$(vEnd)"}>} Quantity*partPieceWeight)

vCoveredQty2  =sum({<[Production Status]={1},[Days]={">=$(vStart) <=$(vEnd)"}>} (shippingUnitTareWeight/packageQuantity)*0.453592)

To calculate the sum of weight, 

vCoveredQty = $(vCoveredQty1)+  $(vCoveredQty2)

 

View solution in original post

6 Replies
Mark_Little
Luminary
Luminary

HI @Husky_Bab12 

It would seem to me something to do withe the data model. the error seems to point to it can't see the quantity field. Is Quantity available against the entire part in the data model?

Husky_Bab12
Contributor
Contributor
Author

By entire part I mean all the different parts. And the tables containing this value are connected in Data Model.

The issue I feel is since I'm calculating sum of quantity on the fly and also the weight together? 

or is it because different parts have unique partpieceweight,shippingtareweight and packagequantity.

Not sure whether I understand you correctly, by your words if that's the case. it should not even show the weights for one part right? 

Digvijay_Singh

Not sure but it appears to me as if you are mixing aggregated results with individual fields. Qlik Sense set analysis operates over the entire data model so using individual field names along with Sum() doesn't make sense to me, may be something like on below lines, may need some refinement as per your logic but try to have everything inside the aggregation function.

vCoveredQty1  =sum({<[Production Status]={1}>} Quantity*partPieceWeight)

vCoveredQty2  =sum({<[Production Status]={1}>} (shippingUnitTareWeight/packageQuantity)*0.453592)

To calculate the sum of weight, 

vCoveredQty = $(vCoveredQty1)+  $(vCoveredQty2)

Husky_Bab12
Contributor
Contributor
Author

Hi @Digvijay_Singh , Your approach works.

But I cannot able to use the  vCoveredQty in the expression

=(sum({<$(='[Days]')={">=$(vStart) <=$(vEnd)"}>} $(vCoveredQty)))

where we give the input days based on which the vcoveredqty need to change.

But the output is entire weight covered remains static and its not changing based on the days input.

Digvijay_Singh

It won't work because you got your expression like this - Sum(Sum()), this is not permitted. But I see you got one new condition for Days, why don't you add that as well in your variable. It will have same effect.

Also your set expression syntax near 'Days' doesn't look right, not sure if its a date field.

={<[Days]={">=$(vStart) <=$(vEnd)"}>} 

You should check at the bottom of expression editor, and see how set conditions are showing result, and keep improving it based on your needs.

vCoveredQty1  =sum({<[Production Status]={1},[Days]={">=$(vStart) <=$(vEnd)"}>} Quantity*partPieceWeight)

vCoveredQty2  =sum({<[Production Status]={1},[Days]={">=$(vStart) <=$(vEnd)"}>} (shippingUnitTareWeight/packageQuantity)*0.453592)

To calculate the sum of weight, 

vCoveredQty = $(vCoveredQty1)+  $(vCoveredQty2)

 

Husky_Bab12
Contributor
Contributor
Author

hI @Digvijay_Singh 

vCoveredQty1  =sum({<[Production Status]={1}>} Quantity*partPieceWeight) Is not providing the expected value.

It is providing bloated  value.

for example , quantity = 7371  and partPieceweight =  0.12.

The expected value is 884.52. 

But the actual output is 1769.

I want to sum the quantity and multiply by partpieceweight?