# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Not applicable

## set analysis vs if

Hello community

lately I discovered the set analysis features for me and they seam to be quite helpful

I'm struggeling a bit with the understanding and the cases when to use what. Maybe you can help.

For getting results for "where" conditions I was using before:

If(DimColor='green',Count(Field1),0)

or Count(If(DimColor='green',Field1,0)

For getting cumulated sums or counts I was using

Count(Total <Dim1, Dim2> Field1) or aggr()

And all of it was quite tricky and also depending whether the datamodel was one table or several rational connected tables.

Additionally sometimes I needed to ajust the datamodel so I could make it work using the above mentioned methods.

With set analysis it seems so easy to get the things work.

So coming back to the question what are the differences of the methods and where should I use what?

Could you give me a quick guideline.

Thank you so much in advance

//chesterluck

Tags (6)
1 Solution

Accepted Solutions
Not applicable

## Re: set analysis vs if

Set analysis is like a selection, that is evaluated before the chart is built. I.e. it cannot be be evaluated row-by-row.

See more on A Primer on Set Analysis, Conditional Aggregations

HIC

3 Replies
Not applicable

## Re: set analysis vs if

Set analysis is like a selection, that is evaluated before the chart is built. I.e. it cannot be be evaluated row-by-row.

See more on A Primer on Set Analysis, Conditional Aggregations

HIC

Not applicable

## Re: set analysis vs if

Ok but in case I have all the values from my datamodel and I dont want the sums and count to ajust after post selections (but really want to cumulate dimensions of my datamodel) then there is nothing wrong in using set analysis.

Or am I wrong?

Not applicable

## Re: set analysis vs if

If you don't want the selections to affect the sums and counts, all you need to do is to use 1 as set definition instead of \$, e.g.

Count({\$<DimColor={'green'}>} Field1)

Count({1<DimColor={'green'}>} Field1)

The top one will respect the selections, and the bottom one will not.

HIC

Community Browser