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 based on selected field

Hi,

I'm trying to calculate a sum based on a selected value from a field.

This is my formula. What is wrong with it?

=sum({<Application = {$(vApplication)}[[Scheduled Loads])

Basically, based on what selected value is in the Application List Box, I want to calculate the Scheduled Loads.

Thanks,

Adrian

14 Replies
Not applicable
Author

=sum({<Application={$(vApplication)}>}[Scheduled Loads])

This is my formula, sorry. Still not working

anbu1984
Master III
Master III

Add quotes around variable

=sum({<Application={'$(vApplication)'}>}[Scheduled Loads])

maleksafa
Specialist
Specialist

if the variable vApplication contain only the application that you want to see then there is no need to add anything in your set analysis just sum([scheduled loads]) and it will take your selected application, now if you have another treatment for that you need to check if the vApplication is a string then you need to add quotes to your filter ={'$(vApplication)'}

Not applicable
Author

It will always display 0, regardless the selection

maleksafa
Specialist
Specialist

can you upload a sample document ?

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

If you are setting vApplication to whatever you have selected in the list box, then this is all redundant. You do not need the variable, and just use =sum([Scheduled Loads]) in your expression.

If you don't want this to calculate or display unless something is selected, you can use conditional display or conditional calculation to prevent display or calculation if nothing is selected, for example:  =GetSelectedCount(Application) > 0

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

The problem here is that, if I have 2 selected values (out of 4 possible), I want two different numbers, not the overall sum

maleksafa
Specialist
Specialist

then you need to add the application filed as a dimension, this way if you select 2 applications you will get one number for each selection

Not applicable
Author

This is the document. Basically, if you see the bar chart, the numbers on the line are "hardcoded", but, what I want to do is whenever there is no value selected in Application, all 4 numbers should be there, but, when one, or two or three Applications are selected, I only want one, two or three number there, on the line graph.

Is that possible?

Thanks,

Adrian