Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional sum in %Expression

Hi all, I'm using the Dynamic chart http://community.qlik.com/media/p/91101.aspx and in the expressions I want to show the sums of the units depending on the dates contained in a field called ReceivedDate. Then in the script I'm doing:

Expresions:
load * inline [
%ExpName, %Expression
Forecast 14/06/2010, sum({$<ReceivedDate={14/06/2010}>}Units)
Forecast 21/06/2010, sum({$<ReceivedDate={21/06/2010}>}Units)
];

but it seems it isn't working: in the chart all the related cells are empty (with the symbol "-"). Do you have any suggestions to solve it?

1 Solution

Accepted Solutions
Not applicable
Author

Hi, b

I think you forgot to put single quote before and after the date in Set Analysis.

Expresions:
load * inline [
%ExpName, %Expression
Forecast 14/06/2010, sum({$<ReceivedDate={'14/06/2010'}>}Units)
Forecast 21/06/2010, sum({$<ReceivedDate={'21/06/2010'}>}Units)
];

This worked with me. Try it.

Kind regards,

Miha

View solution in original post

5 Replies
sparur
Specialist II
Specialist II

May be, problem in Date format? Can you post your qvw

Not applicable
Author

Hi, b

I think you forgot to put single quote before and after the date in Set Analysis.

Expresions:
load * inline [
%ExpName, %Expression
Forecast 14/06/2010, sum({$<ReceivedDate={'14/06/2010'}>}Units)
Forecast 21/06/2010, sum({$<ReceivedDate={'21/06/2010'}>}Units)
];

This worked with me. Try it.

Kind regards,

Miha

Not applicable
Author

You are right. Thanks!

Not applicable
Author

Hi Guys,

I'm doing the same thing except that instead of using set analysis, I used a straight sum and count in my expression.

The expressions basically refer to the column from Table A which is Amount.

I'll be using the Selectmetric column to toggle between count and total in a chart. But when I try to select either Count or Total in the SelectMetric listbox, the expression just displays the text instead of evaluating it. Any ideas ?


TableA:
LOAD * INLINE [
Supplier, Amount
A, 100
B, 200
C, 300
D, 400
D, 500
];


Metric:
LOAD * INLINE [
%SelectMetric, %Expression
Count, count(Amount)
Total, sum(Amount)
];


johnw
Champion III
Champion III

Looks like $(=%Expression) works. See attached.