5 Replies Latest reply: Mar 16, 2015 11:43 AM by Gregoor Kerkhof RSS

    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!

        • Re: Only() question
          Joseph Simmons

          Hi Gregoor,

           

          something like the below set analysis should work for you

           

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

          hope that helps

          Joe

            • Re: Only() question
              Joseph Simmons

              also you might find this

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

              useful for more info on set analysis

               

              Joe

              • 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!