9 Replies Latest reply: Mar 4, 2016 2:47 AM by annick whitfield

# 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...

Annick

• ###### Re: Bar Chart - Measure with division does not work

Qlik is case sensitive with regard to field names, try

• Dimension : Breed
• Measure : Count({\$<Type = {'Dog'}>} ID) / Count({\$<Type = {'Man'}>} ID )
• ###### Re: Bar Chart - Measure with division does not work

I tried:

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

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

• ###### Re: Bar Chart - Measure with division does not work

try these :

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

• ###### Re: Bar Chart - Measure with division does not work

Hello,

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

• ###### Re: Bar Chart - Measure with division does not work

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)

• ###### Re: Bar Chart - Measure with division does not work

Try like that :

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

• ###### Re: Bar Chart - Measure with division does not work

Thank you so much !!! It works perfectly !

• ###### Re: Bar Chart - Measure with division does not work

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?

• ###### Re: Bar Chart - Measure with division does not work

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