Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Simple Sum

sum({<feeddate={$(=addmonths(feeddate,-1))}>} total <[CSS Dimension]>TurnoverPopulationFlag)


I can't get the above expression to work.  If I hardcode feeddate={'5/1/2011'}, it works.  I've also tried using double quotes after looking at examples.

sum({<feeddate={"$(=addmonths(feeddate,-1))"}>} total <[CSS Dimension]>TurnoverPopulationFlag)


Can someone tell me what I'm doing wrong?  Thanks!

14 Replies
danielrozental
Master II
Master II

try with single quotes

sum({<feeddate={'$(=addmonths(feeddate,-1))'}>} total <[CSS Dimension]>TurnoverPopulationFlag)

Do you have a single possible value for feeddate?

Not applicable
Author

Thanks.  I tried with single quotes and that also gives me zeros.  There are definitely values for feeddate.  When I use this expression, addmonths(feeddate,-1) I get the previous month's feeddate for each month selected.  Any other ideas?

danielrozental
Master II
Master II

try this, add a text object to the sheet and have this as the formula

='$(=addmonths(feeddate,-1))'

Not applicable
Author

OK...I'm not really sure what I'm supposed to do.  Which tab in Text Object Properties is the formula supposed to go?  Also, what will adding a text object accomplish? 

danielrozental
Master II
Master II

Yes, text object formula.

It will show you what the expression '$(=addmonths(feeddate,-1))' is resolving to.

You could also try posting a sample app, that will be easier than going back and forth with messages.

Not applicable
Author

the text object remains blank.  I tried diplaying fields and those don't appear either - =feeddate, =Range

Not applicable
Author

the text object remains blank.  I tried diplaying fields and those don't appear either - =feeddate, =Range

danielrozental
Master II
Master II

You will only get a value when there is just one possible option, just like with the expression you're trying to include in your set analysis.

Going back to the basics, what exactly are you trying to achieve in the graph/table?

Not applicable
Author

for any selected date range (Apr 2011, May 2011, Jun 2011, etc), I'm trying to get the average headcount which is defined as current headcount plus prior headcount divided by 2.

((sum(TurnoverPopulationFlag) + sum({<feeddate={$(=addmonths(feeddate,-1))}>} total <[CSS Dimension]>TurnoverPopulationFlag))/2)


I need to look back at the previous month somehow.  I'm confused at to why =addmonths(feeddate,-1) will display results when used alone, but doesn't work when used within the Sum.

addmonths(feeddate,-1)addmonths(feeddate,-1)addmonths(feeddate,-1)sum({<feeddate={''}>} total <[CSS Dimension]>TurnoverPopulationFlag)
//sum({<feeddate={'$(=AddMonths(feeddate,1))'}>} total <[CSS Dimension]>TurnoverPopulationFlag)
sum({<feeddate={''}>} total <[CSS Dimension]>TurnoverPopulationFlag)
//sum({<feeddate={'$(=AddMonths(feeddate,1))'}>} total <[CSS Dimension]>TurnoverPopulationFlag)
sum({<feeddate={''}>} total <[CSS Dimension]>TurnoverPopulationFlag)
//sum({<feeddate={'$(=AddMonths(feeddate,1))'}>} total <[CSS Dimension]>TurnoverPopulationFlag)
Jun 2011May 2011Apr 2011Jun 2011May 2011Apr 2011
5/1/20114/1/20113/1/2011000
5/1/20114/1/20113/1/2011000
5/1/20114/1/20113/1/2011000
5/1/20114/1/20113/1/2011000
5/1/20114/1/20113/1/2011000
5/1/20114/1/20113/1/2011000
5/1/20114/1/20113/1/2011000
5/1/20114/1/20113/1/2011000
5/1/20114/1/20113/1/2011000
5/1/20114/1/20113/1/2011000