Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
curiousfellow
Specialist
Specialist

Problem with correl expression

Why is this expression wrong ?

Correl(({$<

  [Year]={$(HighestYear)},

  MainQuestion ={">=$(=0)"}

>} MainQuestion)

,

({$<

  [Year]={$(HighestYear)},

  [question]={'Otherquestion'},

  score={">=$(=0)"}

>} score))

When I seperate the expression in the part before the comma and after the comma and use it with avg both expressions are correct :

avg ({$<

  [Year]={$(HighestYear)},

  MainQuestion ={">=$(=0)"}

>} MainQuestion)

and

avg ({$<

  [Year]={$(HighestYear)},

  [question]={'Otherquestion'},

  score={">=$(=0)"}

>} score)

Your help will be appreciated

3 Replies
Gysbert_Wassenaar

{$<

  [Year]={$(HighestYear)},

  MainQuestion ={">=$(=0)"}

>} MainQuestion

This is not an expression. You probably have to add an aggregation function and use the aggr function. Perhaps you need something like this:

Correl(aggr(only({$<

  [Year]={$(HighestYear)},

  MainQuestion ={">=$(=0)"}

>} MainQuestion), MyDimension1, MyDimension2, ... , MyDimensionX)

,

aggr(only({$<

  [Year]={$(HighestYear)},

  [question]={'Otherquestion'},

  score={">=$(=0)"}

>} score), MyDimension1, MyDimension2, ... , MyDimensionX))

Replace MyDimension1, MyDimension2, ... , MyDimensionX with the dimensions over which you want to aggregate.


talk is cheap, supply exceeds demand
curiousfellow
Specialist
Specialist
Author

I am really new to Qlikview, and was just studying the aggr function.

I know that it is not an expression, in my expression it is the first part of the correl expression.

Could you please explain why you use so much dimensions in the first part of the correl expression.

When I simplify the correl expression it looks like

Correl(question1,question2)

However I want a value for

Correl(question1,question2) and

Correl(question1,question3) and

Correl(question1,question4) etc

I want the correl values to be presented in a scatter chart, the average of every question has to be the dimension, the correl is the expression.

Thanks for your answer, I certainly will try your expresion

curiousfellow
Specialist
Specialist
Author

I found a solution for this particular problem, looks like this :

Correl(if(Year=Highestyear,if(Mainquestion > 0,Mainquestion)),if(year=Highestyear,if(Mainquestion > 0,if(score > 0,score))))

Probably not the best solution, but works for now