Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
gmenoutis
Partner - Creator II
Partner - Creator II

Dummy field_selection for set analysis?

Let's consider a simple formula with a set analysis:

sum({$<[Transaction Type]={Sale},[Store]={Store1}>} Value)

I need a dummy field selection, something I can put between commas that will not invalidate the formula, but will also not cause any further calculations:

sum({$<[Transaction Type]={Sale},dummy_field_selection,[Store]={Store1}>} Value)

I am currently using:

[Transaction Date]=[Transaction Date]

..but is there something better?

3 Replies
marcus_sommer

What is the aim of this dummy-field?

- Marcus

gmenoutis
Partner - Creator II
Partner - Creator II
Author

It doesn't really have to do with QS. I am storing my formulas in a database table. I very frequently have to create measures of: current year, previous year, difference, growth. In order to do this fast, I have created a keyword that can take the formula of another measure and replace stringA with stringB. Thus, I can create the "current year" measure (which could be 2000 characters long) and the just use replace(ID,curyearsetanalysis,prevyearsetanalisys) to calc the previous year measure and so on. BUT, in a current implementation, the current year set analysis is...$ ! So I have to create a placeholder to be replaced by the previous year set analysis.

marcus_sommer

Each part within the set analysis or anywhere else in an expression must be evaluated and will in general have an impact on the calculation. If there is a better approach then your used one is difficult to say because the needed calc-times are essentially depending from your datamodel and if you used any kind of simplifying to the expressions through an external storing you will need to find your balance between performance, simplicity and maintainability.

I don't use such external storing of expressions unless a few ones which come from include-variables because in my environment it would cause more work and disadvantages as benefits.

Nevertheless I try to avoid redundancy and to simplify the logic and this is quite often be done with variables, variables with parameter or with flags. Here a few examples:

set var = ", PeriodFlag = {'YTD'}";
   or maybe another one
set var = " ";

sum({< Field = {'value'} $(var) >} value)

For such an approach you will probably need some kind of if-loop to return the appropriate value.

Quite more often used are variables with parameter like:

set var = "sum({< PeriodFlag = {'$1'}>} value)";

which is then called with:

$(var(YTD))

or the flag is just use as multiplicator like:

sum(value * YTD)    or      sum(value) * YTD

Essential for the above suggestion is that at least one master-calendar is applied with one or multiple flags and/or an additionally As-Of-Table is created for the flag(s).

It may not look like an answer to your question but I think it may be useful to simplify your expression-handling.

- Marcus