Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ksomosera10
Creator II
Creator II

If-Sum then Count Distinct

Hi!

Can you help me out on my problem?

I have this table and text box. Here's what I need. I want to show in my text box the distinct count of people having a specified criteria and condition.

Just to give you an idea, here's a sample data on my table:

|      Name    |  Power        |  Element |    HP    |

|    Batman  |  Batpower  |      Dark  | 1000    |

| Spiderman |    Web        |  Nature  |  900    |

| Aquaman  |Trident Strike|    Water  |  2000  |

On my text box I want to show this kind of expression:

If Element == 'Nature' and HP <= 1000 Then Count Distinct Name


I hope this helps you understand my problems...

Thanks!

32 Replies
ksomosera10
Creator II
Creator II
Author

35 = Count(DISTINCT Name)

  0 = Count({<Element = {Nature}>} DISTINCT Name)

  5 = Count({<HP = {"=Sum(HP) <=1000"}>} DISTINCT Name)



Do you think there's something wrong with my expression?

Anil_Babu_Samineni

Great, Due to zero issuing facing, May be? Because with in the set analysis , can work as and operator that means It should count when 2 conditions filled. What i state earlier you may not having the Nature as value and Qlik is case sensitive. you can troubleshoot yourself because we don't have any copy file with me..

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
ksomosera10
Creator II
Creator II
Author

Do you want me to sen you a sample file?

Anil_Babu_Samineni

Off course

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
PrashantSangle

might be you are missing ' single quote around value Nature in set analysis {'Nature'}

Like

Count({<Element = {'Nature'}, HP = {"=Sum(HP) <=1000"}>} DISTINCT Name)



Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Anil_Babu_Samineni

I believe, Without that it works

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar

What happens if you use this

Count({<Element = {'*Nature*'}>} DISTINCT Name)

Does this give you a value other than 0?

ksomosera10
Creator II
Creator II
Author

Please wait, I'll create a legit data so that you can check it for yourself.

ksomosera10
Creator II
Creator II
Author

Hi,

I've used a different data but tried to replicate my whole work problem. I hope this will help you out to check why I get these problems. thanks!

Anil_Babu_Samineni

Use this? Because, Sum is not proper with in the set

=Count({<Functional = {'F1'}, Programming = {'P1'}, nAlloc = {"=Sum(Alloc) <= 99"}>} DISTINCT [Resource Name])

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful