Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
divyathomas
Contributor II
Contributor II

How to adjust reference line based on dimension selected in Line Chart?

I have a line chart with 3 dimensions(Year, place, model type, etc). One dimension is chosen at a time and the others are available as alternative dimensions. I have one measure Count(SerialID).

I want to add an average reference line to the chart based on the selected dimension. Currently, when I add an average reference line, say based on the dimension 'year' , that line is visible even when the user selects dimension 'place'. Also, the reference line does not change to show the average of the new selected dimension (place). How can I do this??

 

Labels (2)
1 Solution

Accepted Solutions
forte
Partner - Creator
Partner - Creator

Hi @divyathomas 

May be you can test a workaround. Instead of using alternative dimension, try to do it through a calculated dimension depending on a variable's value

if(vMyVariable=1, Dim1,if(vMyVariable=2, Dim2....)

In order to let the user change dimension, you can use an Input extension (in Qlik Bundle) so you can show some buttons user can action to change that variable , and consequently dimension.

Now you are able to use that variable to decide best expression for reference line.

Hope it helps

Regards

View solution in original post

5 Replies
forte
Partner - Creator
Partner - Creator

Hi @divyathomas 

You can use GetObjectDimension function. It retrieves de name of dimension that you are using on an object on a specific index.

In your case , you can call if(GetObjectDimension(0) ='Year', expressionforavgbyyear,.... 

Hope it helps

Regards

divyathomas
Contributor II
Contributor II
Author

Hello @forte , Thanks for replying. But this isn't working and when looking more into it I think it is because GetObjectDimension can't be used in reference lines (https://help.qlik.com/en-US/sense/September2020/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/Fiel...)

Wondering if you knew some other way of doing this?

forte
Partner - Creator
Partner - Creator

Hi @divyathomas 

May be you can test a workaround. Instead of using alternative dimension, try to do it through a calculated dimension depending on a variable's value

if(vMyVariable=1, Dim1,if(vMyVariable=2, Dim2....)

In order to let the user change dimension, you can use an Input extension (in Qlik Bundle) so you can show some buttons user can action to change that variable , and consequently dimension.

Now you are able to use that variable to decide best expression for reference line.

Hope it helps

Regards

divyathomas
Contributor II
Contributor II
Author

Hello @forte ,

Thank you for the suggestion. I am very new to Qlik so I wonder if you might be able to help me a bit more with implementing this solution. I am stuck with the reference line expression. Here is what I did:

As you suggested, I created a variable (vDim which takes values 1,2,3)

divyathomas_0-1605240480109.png

 

Then I created a calculated field with this expression and used this as the dimension in my chart. The dimension in my chart is updating successfully when I change the vDim value from a dropdown

divyathomas_1-1605240598588.png

I am stuck at the reference line expression. When I enter this expression(since I can't add the calculated field directly)...no line is displayed at all. Wondering if you point out where I am going wrong, please...?

divyathomas_2-1605242704573.png

Thanks in advance for any help!

divyathomas
Contributor II
Contributor II
Author

nevermind, I did it like this and it seems to work ok! 🙂

divyathomas_1-1605249864950.png