Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Bar Chart - Measure with division does not work

Hello,

I am a newbie in Qlik Sense and would really need your help.

I have this table:

IDTypeBreed
1ManNone
2DogNone
3DogBoxer
4ManNone
5DogSpaniel
6DogSpaniel
7ManNone
8ManNone

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 :

 

  • Dimension : breed
  • Measure : Count({$<type = {'Dog'}>} ID) / Count({$<type = {'Man'}>} ID ) 

  

  But it does not work...

Many thanks in advance for your help.

Annick

 

1 Solution

Accepted Solutions
sfatoux72
Partner - Specialist
Partner - Specialist

try these :

Count({$<type = {'Dog'}>} ID) / Count({$<type = {'Man'}>} Total ID )

View solution in original post

9 Replies
swuehl
MVP
MVP

Qlik is case sensitive with regard to field names, try

  • Dimension : Breed
  • Measure : Count({$<Type = {'Dog'}>} ID) / Count({$<Type = {'Man'}>} ID ) 
Not applicable
Author

Thanks for your reply.

I tried:

  • Dimension : Breed
  • Measure : Count({$<Type = {'Dog'}>} ID) / Count({$<Type = {'Man'}>} ID ) 

But I don't get the correct results per breed.

sfatoux72
Partner - Specialist
Partner - Specialist

try these :

Count({$<type = {'Dog'}>} ID) / Count({$<type = {'Man'}>} Total ID )

swuehl
MVP
MVP

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?

brijesh1991
Partner - Specialist
Partner - Specialist

Qlik Products are case-sensitive. So better to use the exact field names. Otherwise no issues at all.

Not applicable
Author

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 ?

  • Dimension1 : Year of Birth
  • Dimension 2 : Breed
  • Measure : Count({$<type = {'Dog'}>} ID) / Count({$<type = {'Man'}>} Total ID )

Many thanks

Annick

swuehl
MVP
MVP

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)

sfatoux72
Partner - Specialist
Partner - Specialist

‌Try like that :

Count({$<type = {'Dog'}>} ID) / Count({$<type = {'Man'}>} Total <[Year of Birth]> ID )

Not applicable
Author

Thank you so much !!! It works perfectly !