Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Highlighted
New Contributor

Qlik Expressions (Direct vs. Set Operations)

Hi - I am wondering what's the difference between typing in directly in the Expression (fx) box directly vs. creating a set operations.


I am baffled a bit because this expression below works perfectly when I write directly in the expression(fx) box: 

sum({<date = {'>=$(=MonthStart(Max(date)))'}>*<date = {'<=$(=MonthEnd(Max(date)))'}>}amount)

But when I create this set expression, current month amount, I get an incorrect answer: 

set current_month_amount= "sum({<date = {'>=$(=MonthStart(Max(date)))'}>*<date = {'<=$(=MonthEnd(Max(date)))'}>}amount";

Any help is appreciated.

Tags (1)
4 Replies
Highlighted
Valued Contributor III

Re: Qlik Expressions (Direct vs. Set Operations)

If you are setting up/storing the expression in a variable, then you have to use $(vVariable) in your other expression wherever you are using this variable.hope that helps.

Highlighted
New Contributor

Re: Qlik Expressions (Direct vs. Set Operations)

Hello, I do call $(current_month_amount), but the amount it gives is incorrect.

Highlighted
Valued Contributor III

Re: Qlik Expressions (Direct vs. Set Operations)

please post your expressions with some sample data.

Highlighted
MVP
MVP

Re: Qlik Expressions (Direct vs. Set Operations)

The problem is that the $ expansions (DSE) are executing even though you may not expect it in a Set statement. You need to break up the DSEs to prevent them executing at this point. You can do this

Set current_month_amount = Sum({<date = {'>=#(=MonthStart(Max(date)))'}> * <date = {'<=#(=MonthEnd(Max(date)))'}>}amount;

Let current_month_amount = Replace(current_month_amount, '#', '$');

or this

Let current_month_amount = "sum({<date = {'>=$" & "(=MonthStart(Max(date)))'}> * <date = {'<=$" & "(=MonthEnd(Max(date)))'}>}amount";

This is only a  problem if the expression is defined in the script on in an inline load. It is not a problem if it is read from an external source.

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