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

Sum formula with criteria similar to sumifs

I have a comparison table that draws data from two different containers with list boxes that I use to filter my comparison results.  One column sums up the sales from one container set and the next column sums up the sales from the other container set and then I have a column that shows the difference.  The sum formula looks like this:  =Sum( {EventComp1} [# of Seats] )  where EventComp1 is the alternate state of one of the containers and the other sum formula just replaces EventComp1 with EventComp2 to get the second set for comparison.

I would like to add some criteria that I can use to filter the whole comparison table to show me the sales that happened prior to 30 days from the event that I'm comparing.  So simply put it would be "sum the sales from EventComp1 that happened before 30 days to the event (or whatever number of days I specify)" and then I would do that same for EventComp2 and the comparison column would give me the difference.

I'm using an input box with a variable called DaystoEvent and so I thought the formula would look something like this:

SUM({EventStartDate - SaleDate>=DaystoEvent},{EventComp1} [# of Seats])

This obviously didn't work, but I can't seem to find the correct syntax for it to work.

9 Replies
tresesco
MVP
MVP

I would suggest to see this discussion

Not applicable
Author

I looked at your link and based on that I've come up with the following, but it still tells me I have an error in my expression.  Can you see where I'm going wrong?

Expression: = Sum( {EventComp1} <DayStart([EventStartDate]) - DayStart([UpdateDate]) >=  [DaystoEvent] >   [# of Seats]  )

tresesco
MVP
MVP

May be like this:

Sum( {EventComp1 < [DaystoEvent]={"$(=(DayStart([EventStartDate]) - DayStart([UpdateDate])) >}   [# of Seats]  )


Assuming DaystoEvent is a numeric field.

Not applicable
Author

DaystoEvent is a numeric field, so you were right in your assumption. 

However, your solution didn't quite work.  I get "Expression OK" at the top of the Edit Expression box, but the column only returns "-".  When the expression is pasted in the dialog box the open parenthesis after "Sum" shows red and there is a red error "^" underneath the second "{".  Any ideas what it could be? 

tresesco
MVP
MVP

Sorry. it was a mistake. Try:

Sum( {EventComp1 < [DaystoEvent]={"$(=(DayStart([EventStartDate]) - DayStart([UpdateDate])) "} >}   [# of Seats]  )


"" and '}' was missing.

Not applicable
Author

It still doesn't quite work and I'm still new enough to not be able to troubleshoot.  I don't know if it helps, but I've added a screen shot of what it looks like.

Expression.png

Not applicable
Author

I just realize you also add a quotation, but it still doesn't change it when I put that in as well.

tresesco
MVP
MVP

One more correction: ')' was missing;

Sum( {EventComp1 < [DaystoEvent]={"$(=(DayStart([EventStartDate]) - DayStart([UpdateDate])) ) "} >}   [# of Seats]  )


If this doesn't work, please share your sample app.

Not applicable
Author

How would I pair down the app to be able to share?  Currently it shows as 200MB on my network. Also, is there a way to share without putting all my company's data on the web?