Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Creating a Static Average Reference line

I am having trouble graphing an accurate average reference line on a chart. I tried figuring out the proper syntax to use for the line's calculated formula. Although the syntax I am using seems to be the most logical, or so it seems from what I have gathered from other Qlik Community threads, the value that it calculates does not match what I have calculated in Excel for the same measurement. What my colleague and I are focusing on is data across different states, regions, and sectors from multiple years. We want to graph two static reference lines, one that displays the average for a certain measurement Nationally and one that measures the average for a specific Region, so that data from states can be compared to those two values. Another addendum: we would like the average to be dynamic only when switching from year to year.

In an effort to graph a Regional average for Region 2, I entered this formula for the line:

avg({$<Region={'Region 2'}>}(M5AN+M5BN+M5CN+M5DN)/(M5AD+M5BD+M5CD+M5DD))

But, that yields a very different value than what I have for the same dimensions in Excel. If anyone has any tips for modifying that expression, please let me know, or if anyone has any other suggestions or questions, we would appreciate the help and support!

Emma L.

2 Replies
sunny_talwar

I guess you need to look here for hints:

Average – Which average?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

In addition to Sunny's suggestion, I recommend using RangeSum() instead of the "+" operator. The difference is that with +, any null in the expression will cause the expression result to be null. RangeSum() will treat nulls as zero.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com