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

Announcements
AWS Degraded - You may experience Community slowness, timeouts, or trouble accessing: LATEST HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Explanation please!!

Can any one explain the following statement

sum(if(YTD, SalesPrice))

Thanks in advance!

1 Solution

Accepted Solutions
gandalfgray
Specialist II
Specialist II

Hi

the statement calculates the Sum of SalesPrice having YTD = -1 (that is true)

View solution in original post

6 Replies
gandalfgray
Specialist II
Specialist II

Hi

the statement calculates the Sum of SalesPrice having YTD = -1 (that is true)

Not applicable
Author

Thanks for the reply.

So, if we dont give any condition, it means true.

Thanks again!

gandalfgray
Specialist II
Specialist II

No there is a condition, the condition is everything before the first "," in the if()-statement.

In this case it happens to be just a field (or variabel) named YTD

YTD can have all kind of values

What you do not have in this case is an "else"-expression.

Not applicable
Author

Ok,  great.  Let me rephrase it.

sum(if(YTD, SalesPrice))

If YTD is 1 it will calculate Sum(Salesprice) or If YTD is true it will calculate Sum(Salesprice)

If YTD is 0 it will do nothing or If YTD is false it will do nothing

Is this correct?

gandalfgray
Specialist II
Specialist II

almost

If YTD is -1 it will calculate Sum(Salesprice)

also I do not know how it is in your case,

YTD can be a field that has a connection to Salesprice

and in that case the Sum will only include those Salesprices where YTD is true

hth

Not applicable
Author

Sounds good.  Thanks for your time.

Have a good one.