Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

TOTAL IN BAR CHART

How can I Show the Count as a Text on a Bar Chart. My expression is  

if((NumberYes/NumberQuestions)<0.858,(NumberYes/NumberQuestions))

I am getting the right number of Bars for example I have 36 Bars.

I wanna display the 36 as a Text box somewhere on the Bar Chart.

I have tried the Followung expression in the Presentation Tab->Text in chart and it works only if you select a Bar. Any Ideas??

if((NumberYes/NumberQuestions)<0.858,Count(Total DISTINCT location_id))

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

Try this:

count(distinct if(aggr((NumberYes/NumberQuestions), location_id)<0.858 location_id))

Hope this helps!

View solution in original post

11 Replies
alexandros17
Partner - Champion III
Partner - Champion III

in presentation -> text in chart, insert your expression then press ok

now press shift +ctrl and move the text where you need

Not applicable
Author

Already Tried that

Not applicable
Author

Hi Ray,

what is your dimension of the chart. Lets call it Dim.

Then this should work:

. . ., Aggr(Count(Total DISTINCT location_id), Dim) )


RR

Not applicable
Author

It works better,atleast I am getting the number now, but I need the count with a condition like below

if((NumberYes/NumberQuestions)<0.858,Count(Total DISTINCT location_id))

jerem1234
Specialist II
Specialist II

Try this:

count(distinct if(aggr((NumberYes/NumberQuestions), location_id)<0.858 location_id))

Hope this helps!

MK_QSL
MVP
MVP

Try this...

if((NumberYes/NumberQuestions)<0.858,Count(DISTINCT location_id))

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

I would have thought the issue is that there is no aggregation on the two values in the division, should it not be something like:

if((sum(NumberYes)/sum(NumberQuestions))<0.858,Count(DISTINCT location_id))


Previously without a single bar selected there would have been multiple values for each of those figures and so they would have been returning NULL.


Steve

Not applicable
Author

That works, now one more question, The numer 0.858 in the above expression is a Hard coded number I wanna replace it with  AVG(NumberYes/NumberQuestions).

I know we cant do the Avg under Aggr

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

I would put it in a variable and refer to it in your expression.

Create a variable vAvgQuestions, with the content:

=AVG(NumberYes/NumberQuestions)

You can then use it in your expression like this:

count(distinct if(aggr((NumberYes/NumberQuestions), location_id)<$(vAvgQuestions)location_id))


I think I missed your initial question, are you trying to count how many bars are under the average?


Cheers

Steve