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: 
Anonymous
Not applicable

Need some help with defining a set analysis formula

Hi Experts,

I'm having trouble correctly defining a set analysis expression in a script. When I use the formula directly in a chart it works as intended. When I try to define it in the script I haven't been able to make it work. Below is a simplified script demonstrating the problem with the qvw attached. When SelectedYear is selected the CYSales value should show the sales for that year.

The Sales chart in the qvw shows the behavior of the formula applied in the script, the chart and via Settings->Valriable Overview

The column labeled 'CYSales_Chart' demonstrates the desired results. Ideally I'd also like to use the CurrentYear variable as opposed to Max(SelectedYear) in the formula.

Any help would be greatly appreciated.

Thanks in advance,

--------

set CurrentYear = Max(SelectedYear);

set LastYear = Max(SelectedYear)-1;

set CYSales_Script = sum( {$<Year = {$(#=Max(SelectedYear))}>} Sales );

Sales:

load * Inline [

Customer, Year, Sales

CustA, 2016, 10000,

CustA, 2017, 12000,

CustA, 2018, 15000,

CustB, 2016, 1000,

CustB, 2017, 1200,

CustB, 2018, 1500,

CustC, 2016, 100,

CustC, 2017, 120,

CustC, 2018, 150,

];

Years:

load Distinct Year as SelectedYear Resident Sales;

1 Solution

Accepted Solutions
2 Replies
swuehl
MVP
MVP

Anonymous
Not applicable
Author

Hi Stefan - that works perfectly. Thanks for your help.