Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

bob_libby_ltb
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;

Tags (1)
1 Solution

Accepted Solutions
swuehl
Not applicable

Re: Need some help with defining a set analysis formula

2 Replies
swuehl
Not applicable

Re: Need some help with defining a set analysis formula

bob_libby_ltb
Not applicable

Re: Need some help with defining a set analysis formula

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