# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QLIKWORLD LIVE! MAY 16 - 19TH, EARLY BIRD DISCOUNTS! REGISTER TODAY
cancel
Showing results for
Did you mean:
Creator

## How can I turn my Count (Distinct If into a set expression?

Is it possible to turn the Count (Distinct expression into a set?

I really hate the performance drainer that count distinct is.

Here is an expression:

Count (Distinct if(Counter='1'and Shop <> '1101' and _YTD_WTY='1',Kvitto))

I'm thinking:

Count ( {< Counter = {'1'}, Shop -= {'1101'} >} Kvitto*_YTD_WTY)

The thing is that when I use the set expression (which works btw) my data changes. I use the formula to calculate number of transactions (Kvitto translates into Receipt in Swedish). So the whole expression is then later divided by visitors.

I can see the changes are small but nonetheless there. Some results change from 2.3% to 2.4% and similar.

Where am I going wrong with this?

1 Solution

Accepted Solutions
MVP

Are you may be missing a DISTINCT?

Count(DISTINCT {< Counter = {'1'}, Shop -= {'1101'}>} Kvitto*_YTD_WTY)

5 Replies

This this way?

Count ( {< Counter = {'1'}, Shop -= {'1101'}, _YTD_WTY={1} >} Kvitto)

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
MVP

Are you may be missing a DISTINCT?

Count(DISTINCT {< Counter = {'1'}, Shop -= {'1101'}>} Kvitto*_YTD_WTY)

Creator
Author

Yeah, this works!

So just a follow-up question; how would the two expressions compare performance-wise? Isn't Count(DISTINCT quite heavy to calculate ? Albeit the removed If-expression should do its part.

MVP

It is a myth as suggested by HIC