Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Only() question

Hi there,

I've been running into a problem I can't seem to work out. I need to count the number of transactions that only contain a treatementcode('K'). A transaction can have many treatment codes, but I only want to distinct count a transaction number if it only contains a 'K'. If it contains another code, it shouldn't get counted. I have tried using only(), but it doesn't seem to work for me the way I want it to. Could you help me with this?

I distinct count a combination field of transaction number &"|"& customer number

Thanks in advance!

Tags (3)
1 Solution

Accepted Solutions
Not applicable

Re: Only() question

Ah right yes that makes a bit more sense then with that example. Have a look at the attached, you'll need to use Aggr for this.

Hope that helps

Joe

5 Replies
Not applicable

Re: Only() question

Hi Gregoor,

something like the below set analysis should work for you

Count({<treatementcode={"*K*"}>} Distinct [transaction number])

hope that helps

Joe

Not applicable

Re: Only() question

also you might find this

http://community.qlik.com/docs/DOC-4951

useful for more info on set analysis

Joe

Not applicable

Re: Only() question

Hi Joe, Thanks for the quick answer. I think your first suggestion isn't exactly what I'm looking for. That way gives me the same results as my current set analysis, which only counts 'K' lines, regardless of other treatment codes. A little example might clarify.

Let's say I have this data:

ID          Transaction#     TreatmentCode

1               1                    R

2               1                    K

3               2                    K

4               3                    R

5               3                    K

What I'm looking for it counting only ID 3, since it only contains a K. The other 2 transcations should not be counted.

Maybe I have already constructed the right set analysis by accident, but I can hardly imagine I did. Just printed your document to study it, thanks for that link!

Not applicable

Re: Only() question

Ah right yes that makes a bit more sense then with that example. Have a look at the attached, you'll need to use Aggr for this.

Hope that helps

Joe

Not applicable

Re: Only() question

Thanks! That is exactly what I'm looking for, now to just edit it to work in my dashboard

Community Browser