Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

set analysis question

Hi Guys,

Why is that I need to create a new field in order for a chart to display a 0 instead of ignoring my selection.

For example:

I have the following expression:

sum({<CompanyName={'A'}>} Sales)

If I select CompanyName B, I would expected that qlikview would return 0 and not ignore my selection

Only if I use a new field CompanyName2 and select B, then Qlikview would return 0.

Do I always have to work that this or is there a simple way so qlikview can retrun 0 without creating a new field.

I've attached my app.

Cheers

Sam

1 Solution

Accepted Solutions
tresesco
MVP
MVP

If you want the expression return always '0' when anything else (apart from 'A') is selected and value only when 'A'/nothing is selected, try with intersection operator('*') like :

sum({<CompanyName*={'A'}>} Sales)

View solution in original post

8 Replies
MayilVahanan

Hi

Try like this

=if(CompanyName = 'A', Sum(Sales), 0)

Uncheck Suppress Zero Values in Presentation Tab.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
tresesco
MVP
MVP

If you want the expression return always '0' when anything else (apart from 'A') is selected and value only when 'A'/nothing is selected, try with intersection operator('*') like :

sum({<CompanyName*={'A'}>} Sales)

Not applicable
Author

Expression as :

=if(CompanyName = 'A', Sum(Sales), 0)

Anonymous
Not applicable
Author

that was exactly what i was looking for. Better than creating new fields.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

I think you're missing something about Set Analysis.

In your example, you replace the current CompanyName selection with a forced selection as detailed by the set modifier <CompanyName={'A'}>. This is only temporarily (for this object) and for this expression.

The behaviour you expect can be accomplished by enabling the checkbox "Show All Values" in Properties->Dimensions and by disabling the checkbox Suppress Zero-Values in Properties->Presentation.

But then, what is the use of displaying all dimension field values and showing only aggregation results for a single company as specified by the set specification?

Anonymous
Not applicable
Author

Only think I curious is why does qlikview underline the expression in red. It gives the impression that the expression is incorrect.

screenshot.jpg

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Weird. You will still not get any other dimension values because zeroes will be suppressed by default in your chart. And if you disable zeroe suppression, you'll get a NULL value in your dimension column.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Don't worry; there are some set analysis constructs that are too smart even for the syntax checker. As the line above your expression states, the Expression is OK.