Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to set up dynamic monthly counts in "text in chart" field

Our client requested the following text on the top of a chart:

Feb 2013 (n=100)  Mar 2013 (n=200)  Apr (n=300) ... up to the last month

I would really like to set that up dynamically like it is possible in a list box by MYear with calculated expression

=' (n='&Count(MYear)&')'

MYear is calculated on the load like

LOAD MonthName(Monthstart(date(DATEFILED))) as MYear

Any help is greatly appreciated

Thank you very much!

1 Solution

Accepted Solutions
Not applicable
Author

The last post doesn't work, but there is another solution:

to use calculated dimension as

=MYear&' (n='&aggr(Count(MYear),MYear)&')'

Capture 5.JPG.jpg

View solution in original post

16 Replies
er_mohit
Master II
Master II

Try this

=subfield(getcurrentselection(),':',-1)&' '&' (n='&Count(MYear)&')'

Not applicable
Author

in script-


LOAD MonthName(Monthstart(date(DATEFILED))) as MYear

month(date(Datefield)) as month

then use this

= 'n= ' & count(if(Datefield>=MonthStart(max(Datefield) and Datefield<=MonthEnd(max(Datefield)),MYear))

Not applicable
Author

I got

(n=5022)

which is the total number for 6 months

stigchel
Partner - Master
Partner - Master

I think the 'text in chart' expression is not evaluated over the dimension. It would be easier if you just added an expression in the expressions tab (=' (n='&Count(MYear)&')') and deselect the line/bar and select the text on axis option. (I'm assuming MYear is your dimension)

Not applicable
Author

That expression does not return any results. I really believe that aggr function has to be involved.

Thank you anyway!

Not applicable
Author

This is a really good approach, but I have another dimension beside MYear and counts really get messed.

Could be good for other charts

Thanks a lot

stigchel
Partner - Master
Partner - Master

Ah, you have a second dimension....To prevent the messiness (multiple texts are plotted over each other) use this:

     if(rowno()=1,YourExpression,'')

Not applicable
Author

This is the best approach I got with the following expression:

= if(RowNo(TOTAL)=1,MYear&' (n='&aggr(Count(MYear),MYear)&')','')

Capture2.JPG.jpg

I get the right number for the first month, but cannot see other months.

When I do not use TOTAL,

= if(RowNo()=1,MYear&' (n='&aggr(Count(MYear),MYear)&')','')

I get :

Capture 3.JPG.jpg

stigchel
Partner - Master
Partner - Master

I'm afraid I haven't been looking very good at your dimensions. Normally I use this technique where the periods are the first dimension, the Rowno()=1 is there to display only for each first value of the first dimension (make an excel export to see what I mean). The expression is also without aggregates as I do not need them (the dimensions are doing the aggregations) and the base values are displayed to the corresponding dimension values.

In your case that would mean displaying the base for each value in the period 5 times, for which there is no room. Unless offcourse you change the display of the labels to vertical (in propertiestab axes). Not very nice but you also can't display the months bases for each value of the other dimension as there are only five and you have six months