Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Not applicable
Author

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
Not applicable
Author

Hi Gregoor,

something like the below set analysis should work for you

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

hope that helps

Joe

Not applicable
Author

also you might find this

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

useful for more info on set analysis

Joe

Not applicable
Author

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
Author

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
Author

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