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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

if or where?

I have a simple expression where the dimension is YEAR. For the year 2010, my expression gives me the incorrect total (this is because the source data is incorrect and I cannot change it) so for 2010 I need to add an extra 4 to the count - how can I do this?

Sum({1<StatusFlagID={'*1*'}, IncidentType={'*Accident*'}, ListTitle={'*Employee*'}>}StatusFlagID)

Thanks

1 Solution

Accepted Solutions
swuehl
MVP
MVP

You need to use either

rangesum(sum(....), if(YEAR=2010,4))

or

sum(....) + if(YEAR=2010,4,0)

if(YEAR=2010,4) will return NULL for all YEAR <> 2010, and adding NULL to something returns NULL (rangesum will handle this gracefully).

Hope this helps,

Stefan

View solution in original post

3 Replies
diegofcaivano
Partner - Creator
Partner - Creator

Hi,

If you have data inconsistency, I would very much recommend you to fix it in the script and not in the object expression. Not even in the front-end application script but on a previous transformation level of QVWs.

However, you can add it like this:

SUM(...) + IF(YEAR=2010, 4)
Not applicable
Author

that doesn't seem to be working..any ideas?

swuehl
MVP
MVP

You need to use either

rangesum(sum(....), if(YEAR=2010,4))

or

sum(....) + if(YEAR=2010,4,0)

if(YEAR=2010,4) will return NULL for all YEAR <> 2010, and adding NULL to something returns NULL (rangesum will handle this gracefully).

Hope this helps,

Stefan