Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

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
Valued Contributor

Re: Bar Chart - Measure with division does not work

try these :

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

9 Replies
MVP
MVP

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 ) 
Not applicable

Re: Bar Chart - Measure with division does not work

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
Valued Contributor

Re: Bar Chart - Measure with division does not work

try these :

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

MVP
MVP

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?

brijesh1991
Contributor III

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.

Not applicable

Re: Bar Chart - Measure with division does not work

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

MVP
MVP

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)

sfatoux72
Valued Contributor

Re: Bar Chart - Measure with division does not work

‌Try like that :

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

Not applicable

Re: Bar Chart - Measure with division does not work

Thank you so much !!! It works perfectly !

Community Browser