Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I am a newbie in Qlik Sense and would really need your help.
I have this table:
ID | Type | Breed |
---|---|---|
1 | Man | None |
2 | Dog | None |
3 | Dog | Boxer |
4 | Man | None |
5 | Dog | Spaniel |
6 | Dog | Spaniel |
7 | Man | None |
8 | Man | None |
I would like to show, per breed, the number of dogs divided by the number of men (Imagine we're looking for the most popular breed based on how many people owns them) :
I use a bar chart with :
But it does not work...
Many thanks in advance for your help.
Annick
try these :
Count({$<type = {'Dog'}>} ID) / Count({$<type = {'Man'}>} Total ID )
Qlik is case sensitive with regard to field names, try
Thanks for your reply.
I tried:
But I don't get the correct results per breed.
try these :
Count({$<type = {'Dog'}>} ID) / Count({$<type = {'Man'}>} Total ID )
What would be correct results then?
Based on your sample table, you don't have type man for breeds Spaniel and boxer, so you divide by zero.
Breed None should return 1/4, right?
Qlik Products are case-sensitive. So better to use the exact field names. Otherwise no issues at all.
Hello,
Thanks a lot for your answer, it works great !
If I may, could I ask another question? I would like to add a dimension in order to show the evolution of the most popular breed across the years. How can I have the <Total Men> per year (and not summed on all the years) ?
Will the following work in a stacked bar chart ?
Many thanks
Annick
You can use the TOTAL qualifier with a field list, so in your case, something like
Count( {$<type = {'Dog'}>} ID ) / Count({$<type = {'Man'}>} TOTAL<[Year of birth]> ID)
Try like that :
Count({$<type = {'Dog'}>} ID) / Count({$<type = {'Man'}>} Total <[Year of Birth]> ID )
Thank you so much !!! It works perfectly !