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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression to sum based upon criteria regardless of what is selected

Hi,

I have a few fields and I need to be able to have a total field for a year. i.e. If a user selects year 2008 regardless of anything else selected the field needs to show the total costs for 2008 or if the user selects 2009 it will show the total for 2009.

Any help would be appreciated.

Thanks.

5 Replies
Not applicable
Author

Using Set analysis,

you can do a sum({1<Year={$(=only(YearField))}>} FieldToSummarize)

The number 1 will run the sum for every data whatever selection is.

By doing this be careful that performances are good ( Making a sum on all values can be longer, depending on the amount of data)

Hope this helps.

Rgds,

Sébastien

Not applicable
Author

Thanks for your reply,

I am using 8.2, is set analysis for version 8.5, if so how would i obtain the same result in 8.2

thanks again

Not applicable
Author

No I don't think it will work (check in your tutorial).

In this case you have to do Sum(ALL IF(Year=$(=only(Year)),FieldToSummarize,0))

Rgds,

Sébastien

Not applicable
Author

Hi,

I have tried the following expression

Sum(ALL IF(Year= $(Year),MYCOST,0))

however it is only returning a '-' i.e. no data

what am i missing?

Thanks



Not applicable
Author

I think you should replace Year = $(Year) by Year = $(=only(Year)).