Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Guilgo
Partner - Contributor III
Partner - Contributor III

Problem with Sum(if())

Hey,

 

I have a problem with a formula: I want to calculate the sum of a field's values only if another field is greater than 1 (or 2, 3...).

I want to calculate the sum of my "available stock" column, for each product hierarchy group (I have a "group level" column which takes the value 1, 2, 3, 4, 5)


I've tried this formula :

 

Sum(if(group_level>=1, available stock))

 

but it returns 0

 

The column "group level" is not in the same table than available stock but both tables are linked

 

What is the problem ? 

 

 

Labels (2)
8 Replies
Mark_Little
Luminary
Luminary

Hi

Something like

SUM(<group-level={">1"}>)[available stock])

Guilgo
Partner - Contributor III
Partner - Contributor III
Author

it doesnt work ...

 

I tried this : SUM({<group-level={">1"}>}available stock) it returns 0 too

Guilgo
Partner - Contributor III
Partner - Contributor III
Author

up

Tanish
Partner - Creator
Partner - Creator

Hi @Guilgo ,

Try this out-

if(  group_level  >=1 , Sum( [available stock]   ) )

 

Your field is having space you should keep that in square brackets.

 

Hope this will help...........

Thanks,

Tanish

 

 

Guilgo
Partner - Contributor III
Partner - Contributor III
Author

it doesnt work

it doesn't return anything, maybe because group_level is  field and I can't compare it to any value 

 

 

Guilgo
Partner - Contributor III
Partner - Contributor III
Author

SUM({<group-level={"=1"}>}available stock) returns a value but the same as SUM({<group-level={"=2"}>}available stock etc...) (and the same as SUM({<group-level={"=8"}>}available stock) while the maximum value for group_level is 5...)

Guilgo
Partner - Contributor III
Partner - Contributor III
Author

Count({<group-level={"=3"}>}group-level) returns the total of number of rows .... filter doesnt work

Gabbar
Specialist
Specialist

Could you please check from data model viewer if your group-level field datatype is numerical integer or text.