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: 
Anonymous
Not applicable

Doubts about using expresions

Hi,

question 1:

I have 2 questions about using expresion.

In a chart I have two expresion:

exp1=sum(sales)        /* exp1 is the label */

exp2=above(sum(sales,1))   /* exp2 is the label */

I want to create exp that is:

exp3 = (exp1 - exp2)/exp1

How can I use exp1 and exp2 in the definition of exp3. I don't have this option in expresion editor. I know I can create two variables with the exp1 and exp2 and the use

exp3 = ($(exp1) - $(exp2))/$(exp1)

But I only need this expresion in this char , is there nay other option??

----------------------------

question2:

I have this expresion:

avg(sum(sales), city, product)

I need to get this value for all data in my model and after I want to use it in several expresions.

If I define a var (panel variable) var=avg(sum(sales), city, product)

the result changes and depens on the dimensions I use in my table or chart.

How can I calculate this expresion for all data and store the value in a variable??

Thanks in advance

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I think exp2 should probably look like

=above(sum(sales),1)


You should be able to reference the expressions using the labels, so I think this should just work


= (exp1 - exp2)/exp1


How do your labels look like in your real setting? Maybe try

= ("exp1" - "exp2")/"exp1"


Your other expression should probably make use of advanced aggregation:


=avg(Aggr( sum(sales), city, product))


If you definey your variable with a leading equal sign, the result should be evaluated in total context.


You may also try

=avg(TOTAL Aggr(sum(sales), city, product))



View solution in original post

1 Reply
swuehl
MVP
MVP

I think exp2 should probably look like

=above(sum(sales),1)


You should be able to reference the expressions using the labels, so I think this should just work


= (exp1 - exp2)/exp1


How do your labels look like in your real setting? Maybe try

= ("exp1" - "exp2")/"exp1"


Your other expression should probably make use of advanced aggregation:


=avg(Aggr( sum(sales), city, product))


If you definey your variable with a leading equal sign, the result should be evaluated in total context.


You may also try

=avg(TOTAL Aggr(sum(sales), city, product))