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: 
arethaking
Creator II
Creator II

Average Calculation

Hi All,

I have the monthly Sales data per PersonID like below.

  

PersonIDYearYearMonthSales
P120162016011
P120162016022
P120162016033
P120162016044
P120162016055
P120162016066
P120162016077
P120162016088
P120162016099
P1201620161010

How to calculate YTD Sales Average?

Expression: sum(Sales)/count(distinct Month)

1 Solution

Accepted Solutions
varshavig12
Specialist
Specialist

avg({<YearMonth={">=$(=YearStart(Max(YearMonth)))<=$(=Max(YearMonth))"}>} Sales)

View solution in original post

3 Replies
MK_QSL
MVP
MVP

Try this

avg({<Year = {'$(=Max(Year))'}>}Sales)

varshavig12
Specialist
Specialist

avg({<YearMonth={">=$(=YearStart(Max(YearMonth)))<=$(=Max(YearMonth))"}>} Sales)

girirajsinh
Creator III
Creator III

Hi Aretha

For your case of Avg.qvw,

try

sum({<Year={$(=Max(Year))},YearMonth={"<=$(=max(YearMonth))"}>} Sales)/count({<Year={$(=Max(Year))},YearMonth={"<=$(=max(YearMonth))"}>}distinct Month)