Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Formula environment

Hello,

is it possible to know if I'm applying a formula in a dimension environment or in expression one?

I've got a nested formula and the more internal is an Aggr() which doesn't work properly if applied in an expression, so I've thought to solve the problem with something like this:

If ('I'm in a dimension', Aggr(Sum(WorkedHours), ProductName), Sum(WorkedHours))

If my aim isn't achievable and somebody has a good idea, I'd be happy to evaluate it.

Thank you.

N.

1 Solution

Accepted Solutions
marcus_sommer

Redundant expressions or parts of it could be put in variables and by using variables with parameter they could be dynamically in some way and also be used as customized functions. By keeping the logic within external (excel) files the expressions could be shared between multiple applications.

But it's not really possible/sensible to create expressions which could recognize their context and would be always fitting. If I refer to your example you could provide the context through a variable, for example:

var:
If($1, Aggr(Sum(WorkedHours), ProductName), Sum(WorkedHours))

and the expression-call could be:

$(var(1))

but like already mentioned I wouldn't recommend it because it will cause a bad performance and is IMO a poor design.

Quite often are contructs like above and/or the approach to put (nearly) everything into variables a massive overusing of the feature and the opposite to the main-idea to keep things as simple as possible - it will reverse the benefits into disadvantages.

Nevertheless here you will find many useful information about: Variables.

- Marcus

View solution in original post

4 Replies
marcus_sommer

Unfortunately there is no "Me.Properties" feature available and therefore it's not possible to detect if it's a dimension, expression, label or anything else in which an expression are - whereby IMO it would be not very helpful to apply such a construct like aimed from you. The readability of the expression is worser as necessary, the performance will be decreasing more or less heavily and it won't help in cases where the aggr() isn't defined properly or just not mandatory.

- Marcus

 

Anonymous
Not applicable
Author

Hi Marcus,

thank you for the reply.

Have you got any suggestion for my issue?

The extrema ratio is to duplicate all the formulas, but it would cause a similar-formula proliferation...

Thks.

N.

marcus_sommer

Redundant expressions or parts of it could be put in variables and by using variables with parameter they could be dynamically in some way and also be used as customized functions. By keeping the logic within external (excel) files the expressions could be shared between multiple applications.

But it's not really possible/sensible to create expressions which could recognize their context and would be always fitting. If I refer to your example you could provide the context through a variable, for example:

var:
If($1, Aggr(Sum(WorkedHours), ProductName), Sum(WorkedHours))

and the expression-call could be:

$(var(1))

but like already mentioned I wouldn't recommend it because it will cause a bad performance and is IMO a poor design.

Quite often are contructs like above and/or the approach to put (nearly) everything into variables a massive overusing of the feature and the opposite to the main-idea to keep things as simple as possible - it will reverse the benefits into disadvantages.

Nevertheless here you will find many useful information about: Variables.

- Marcus

Anonymous
Not applicable
Author

Thank you, Marcus.

Very exhaustive explanation.

N.