Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
SamQlik
Contributor
Contributor

SUM IF executing multiple times in expression

I'm puzzled by the logic being executed in  an expression when two snippets of code are used.

 

Firstly, if I run this piece of code, it returns 1, as expected:

=SUM(
	IF(false(),
	1,
	1)
)

 

However, if I modify the formula slightly and replace the success variable to be summed with an actual field, the formula returns 24 which happens to be the count of the field as well:

=SUM(
	IF(false(),
	myField,
	1)
)

 

Does anyone understand why this is happening and how can I get around it?

 

Thanks

Labels (2)
1 Solution

Accepted Solutions
Or
MVP
MVP

Presumably, the first expression is evaluating once because it's just an empty function, while the second expression is evaluating once per myField value, so 24 times.

It sounds like what you're after is actually:

If(False(),Sum(Myfield),1)

View solution in original post

1 Reply
Or
MVP
MVP

Presumably, the first expression is evaluating once because it's just an empty function, while the second expression is evaluating once per myField value, so 24 times.

It sounds like what you're after is actually:

If(False(),Sum(Myfield),1)