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

Year to Date Average Set Analysis

Hello.

I am trying to calculate the year to date average based on year selected. I do have a Master Calendar with a YearMonth field.

I would like to build a Set Analysis expression so that when certain criteria are fulfilled it calculates my average.

Below is a sample of data where the average value should fall in the Completion Month. As shown in the data, January value will be zero, anyway to force the zero in the chart when there is no value as well (null).

Criteria for the Set analysis expression is:

Products (All)

Product Type (Mens, Women)

YTD Average of days based on End Date.

 

ZoeM_0-1712847454672.png

 

 

 

Labels (1)
1 Solution

Accepted Solutions
ZoeM
Specialist
Specialist
Author

So I was able to find a solution that fits my needs by using the Range expression combined with Set analysis.

 

Below is my expression, make sure you do not select accumulate since the expression itself will do that for you. 

RangeSum(above((sum({$<[Date Type]={'Sale Date'},Products={'Shoes','Shirts','Socks'},Sale={'Y'}>} [Business Days Late])), 0, rowno()))
/
RangeSum(above((Count({$<[Date Type]={'Sale Date'},Gateways={'Shoes','Shirts','Socks'},Sale={'Y'}>} [product line])), 0, rowno()))

I hope this helps someone else. And thanks for everyone who helped me come to this solution. 

 

 

View solution in original post

5 Replies
mpc
Partner - Creator III
Partner - Creator III

Hi, 

Maybe this one ?

Avg({<Product=,[Product Type]={'Mens,Womens'},[Start Date]={">= $(=YearStart(Today()))"}, [End Date]={"<= $(=Today())"}>} Days) 

I haven't tested it !

Regards

ZoeM
Specialist
Specialist
Author

Thanks @mpc 

However it did not change the data/work as expected. 

mpc
Partner - Creator III
Partner - Creator III

So I need to test it. I'll be back (Terminator voice) 

mpc
Partner - Creator III
Partner - Creator III

Maybe this one: 

Avg({< Product=,[Product Type]={'Mens','Womens'},YearMonth=,[Start Date]={">=$(=YearStart(YearMonth))"},[End Date]={"<=$(=(Today()))"} >} Days)

maximepiquetcointe_0-1712921720585.png

 

ZoeM
Specialist
Specialist
Author

So I was able to find a solution that fits my needs by using the Range expression combined with Set analysis.

 

Below is my expression, make sure you do not select accumulate since the expression itself will do that for you. 

RangeSum(above((sum({$<[Date Type]={'Sale Date'},Products={'Shoes','Shirts','Socks'},Sale={'Y'}>} [Business Days Late])), 0, rowno()))
/
RangeSum(above((Count({$<[Date Type]={'Sale Date'},Gateways={'Shoes','Shirts','Socks'},Sale={'Y'}>} [product line])), 0, rowno()))

I hope this helps someone else. And thanks for everyone who helped me come to this solution.