Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Segmented Average Lines in Chart

Hello,

I am pretty new with QlikView and now developing some dashboard for my organization. Currently, the line chart has total sale by month-year for 3 years and I would like to add an line for average sale. This average line is not the grand average across all years. For each year, the average line is the average for that year. For example, from Jan-2010 to Dec-2010, the average line is the average value for Year 2010, and from Jan-2011 to Dec-2011, the line is the average for Year 2011. Is there a way to do it. I assume this can be done with set analysis? But can someone let me know what would be the correct expression?

Thank you so much!

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Do you want to display a line for the monthly average for each year? See attached. It would be something like:

=aggr(NODISTINCT

avg(

aggr(NODISTINCT Sum(TOTAL<Year,[Month-Year]>Sales),[Month-Year])

)

,Year)

-Rob

View solution in original post

7 Replies
rustyfishbones
Master II
Master II

this video will give you some ideas how to start doing this

https://www.youtube.com/watch?v=ruyfe1Mq0iU

Here are some examples of what the Expression Definition might look like

avg({<Year={2011}>} Value)

avg({<Year={2012}>} Value)

avg({<Year={2013}>} Value)

Not applicable
Author

Thank you Alan; however, in this case, we need to specify the year. The data will change yearly, so is there any dynamic way that would automatically change the average calculation based on available data.

Thanks,

Jihan

Not applicable
Author

Thank you Alan; however, in this case, we need to specify the year. The data will change yearly, so is there any dynamic way that would automatically change the average calculation based on available data.

Thanks,

Jihan

rustyfishbones
Master II
Master II

You can add

Year (today ()) for this year

Year (today ())-1 for last year

Is that that what you mean

rustyfishbones
Master II
Master II

The Expressions would be wriiten like

AVG({<Year={$(=Year(Today()))}>}Value) for this Year

AVG({<Year={$(=Year(Today())-1)}>}Value) for last Year

AVG({<Year={$(=Year(Today())-2)}>}Value) for previous Year

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Do you want to display a line for the monthly average for each year? See attached. It would be something like:

=aggr(NODISTINCT

avg(

aggr(NODISTINCT Sum(TOTAL<Year,[Month-Year]>Sales),[Month-Year])

)

,Year)

-Rob

Not applicable
Author

Thank you Rob. It works!