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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
balasundaram
Creator II
Creator II

how to add?

='Total '& Count([Moc.Type  .])+Count(Moc.Type.)

above expression i written in under presentation tab in "TEXT IN CHART" , i am trying to show total count,but i used sum not working

1 Solution

Accepted Solutions
IAMDV
Master II
Master II

Good to know it works for you. But it's not QlikView's fault but that's natural behaviour in programming paradigm. The reason for this behaviour is the nature of the operators used in the expression and the order of precedence. I would recommend you to read - The Order of Precedence of arthimetic operators for clear understanding. However, Let me try to explain:

='Total '& (Count([Moc.Type  .]) + Count([Moc.Type.]))


Above expression won't work without the brackets (in red colour) because we are using "+"/addition arthimetic operator and when we use the brackets then QlikView aggregates the both the count values and then adds them together. So if there are no brackets the expression evaulation might be confusing with the string concatenation operator and it returns a NULL value.


However, below expression works without the same brackets when we use the "*"/multiplier arthimetic operator because this operator take first precedence when we don't specify any brackets.

='Total '& Count([Moc.Type  .]) * Count([Moc.Type.])


So, it's important to explicity specify the brackets whenever writing the expressions and not depending on the Order of precedence.


I hope all this makes sense!


Cheers,

DV


www.QlikShare.com

View solution in original post

10 Replies
MarcoWedel

please provide sample app/data

JonnyPoole
Former Employee
Former Employee

If you change it to just the word total does it work? If not try changing the font color to make it more conspicuous it may be hidden.

If the word total by itself works then add the 1st count by itself and see if that works...  This should tell you which part of your 3 part expression is failing.

IAMDV
Master II
Master II

Hi,

Looking at your expressions there are two potential issues.

balasun per wrote:

='Total '& Count([Moc.Type  .])+Count(Moc.Type.)

1. Your second expression i.e. Count(Moc.Type.) should be Count([Moc.Type.]). I'm not sure if these are right field names but I recommend you to use the square brackets around the field names when there is period or space.

2. When you are aggregating the data (In your case - it's Count) in different expressions and using a string concatenation operator, you need  brackets around the two aggragation expressions (See the read brackets marked below).

So you need to use something like this:

='Total '& (Count([Moc.Type  .])+Count([Moc.Type.]))

I hope this helps!

Cheers,

DV

www.QlikShare.com

israrkhan
Specialist II
Specialist II

Yes, its not working.... dont know why...

but if you keep Total at the end then its working..like below..

= sum(Sales)  + Count(Sales)&'   Total ...............its working

OR you just do sum and count in "text in chart" and create a text object for Total, make it transparent, and just put it left to your total value...

Hope it helps....

preminqlik
Specialist II
Specialist II

hi ,

keep it in variable like

='Total : '&(Count(field)+count(Field2))...and use that variable

IAMDV
Master II
Master II

Prem - Curious to know, how will variable help compared to normal expression?

israrkhan
Specialist II
Specialist II

me too...  🙂

have tried, not working even in variable...

IAMDV
Master II
Master II

This expression works for me:

So you need to use something like this:

='Total '& (Count([Moc.Type  .])+Count([Moc.Type.]))


Cheers,

DV

israrkhan
Specialist II
Specialist II

Yes, for me too...

but logically these () does not make sense.

I consider it, a qlikview fault......

anyway Thanks for.......