Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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!

1 Solution

Accepted Solutions
Highlighted
Not applicable

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

View solution in original post

5 Replies
Highlighted
Not applicable

Hi Gregoor,

something like the below set analysis should work for you

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

hope that helps

Joe

Highlighted
Not applicable

also you might find this

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

useful for more info on set analysis

Joe

Highlighted
Not applicable

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!

Highlighted
Not applicable

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

View solution in original post

Highlighted
Not applicable

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