Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help With Set Analysis

Hi Guys

Looking for some Set Analysis experts please

Please can someone tell me what is wrong with this expression please?

     =Money(sum({1<Year(LOAD_DATE)={"$(=Year(Today()-10))"}>}(POSTED_DEBIT-POSTED_CREDIT)))

Just cannot see what is wrong with this

Although the expression builder says "Expression OK", I am getting the error "Error: Error in set modifier expression"

Thanks

John

1 Solution

Accepted Solutions
Not applicable
Author

Also rather than using the two fields in the sum, you might want to consider doing that in the script also and then the sum can be based on a single field. Just makes it performan better on the front end that way

View solution in original post

5 Replies
Not applicable
Author

Hi John,

set analysis needs to be based on real fields, so using Year(LOAD_DATE) as a modifier won't work.

If you create a year field in your model, you can then use that

year(LOAD_DATE) as LOAD_YEAR

in the script

then expression

Money(sum({1<LOAD_YEAR={"$(=Year(Today()-10))"}>}(POSTED_DEBIT-POSTED_CREDIT)))

hope that helps

Joe

tresesco
MVP
MVP

=Money(sum({1<Year(LOAD_DATE)={"$(=Year(Today()-10))"}>}(POSTED_DEBIT-POSTED_CREDIT)))

The highlighted part is the one causing issue. You can't compare a calculated dimension/field in set analysis. You can only use script generated fields in set comparison (left hand side of '=' sign).

jonathandienst
Partner - Champion III
Partner - Champion III

The LHS of a set expression can only be a field name, not an expression. I would define a year field in the load script like this:

     LOAD ....

          Year(LOAD_DATE) As LoadYear,

           ...

Then use:

     =Money(sum({1<LoadYear = {"$(=Year(Today()-10))"}>} (POSTED_DEBIT-POSTED_CREDIT)))

HTH

Jonathan

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

Also rather than using the two fields in the sum, you might want to consider doing that in the script also and then the sum can be based on a single field. Just makes it performan better on the front end that way

Not applicable
Author

Thanks VERY much everyone, great answers very clear, and MUCH appreciated.