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

Showing line based on selection

Hi All,

I want to show line style for ySales based on the selection.

By default it will show max year data and ySales will show dotted line from AUG to DEC as xSales will be zero from SEP.

My requirement is :

When Feb is selected, JAN should show line, and remaining months dotted line.

When Feb is selected, JAN,FEB should show line, and remaining months dotted line.

When Mar is selected, JAN,FEB,MAR should show line, and remaining months dotted line.

.

.

.

By default, JAN it is showing correct. But when I select FEB, JAN data is showing dotted line, FEB line, remaining Months line.

I want JAN,FEB should be dotted line.

I am using this Line Style formula:

If(Month<vMaxDate,'<S1>','<S4>')

Please help me.

Issue:

Capture.PNG

Requirement:

Capture.PNG

Load * inline [

Month,xSales,ySales

JAN-16,10,15

FEB-16,20,25

MAR-16,30,35

APR-16,40,45

MAY-16,50,55

JUN-16,60,65

JUL-16,70,75

AUG-16,80,85

SEP-16,,95

OCT-16,,105

NOV-16,,125

DEC-16,,135

];

14 Replies
sunny_talwar

How about this:

If(GetSelectedCount(Year) = 0,

If(Month <= AddMonths(MaxDate, -1), '<S1>', '<S2>'),

If(Only({1}Month)<Max(TOTAL Month),'<S1>','<S2>'))

sunny_talwar

Or if you want to use your variable instead of the field, then this:

If(GetSelectedCount(Year) = 0,

If(Month <= AddMonths($(vMaxDate), -1), '<S1>', '<S2>'),

If(Only({1}Month)<Max(TOTAL Month),'<S1>','<S2>'))

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Variable:

vSelectedDate = Date(If(Max(Date) < vMaxDate, Max(Date), vMaxDate))

Expression:

SUM({$<Year={$(=max(Year))},Month=,MonthName=, Date={'<=$(=vSelectedDate)'}>}xSales) +

SUM({$<Year={$(=max(Year))},Month=,MonthName=, Date={'>$(=vSelectedDate)'}>}ySales)

Background Color Expression:If(Only({<Year={$(=max(Year))},Month=,MonthName=, Date={'<=$(=vSelectedDate)'}>} Date), RGB(0, 255, 0), RGB(0, 0, 255))

Line Style Expression: If(Only({<Year={$(=max(Year))},Month=,MonthName=, Date={'<=$(=vSelectedDate)'}>} Date), '<S1>', '<S2>')

Regards,

Jagan.

jagan
Luminary Alumni
Luminary Alumni

Please find attached file for solution.

Regards,

Jagan.

jagan
Luminary Alumni
Luminary Alumni

Forgot to mention derived a new date field in script.

DATA:

load *,

year(Month) as Year,Month(Month) as MonthName;

Load date#(Month,'MMM-YY') as Month,

Date(date#(Month,'MMM-YY')) as Date,

xSales,ySales inline [

Month,xSales,ySales

JAN-16,10,15

FEB-16,20,25

MAR-16,30,35

APR-16,40,45

MAY-16,50,55

JUN-16,60,65

JUL-16,70,75

AUG-16,80,85

SEP-16,,95

OCT-16,,105

NOV-16,,125

DEC-16,,135

];

SalesDate:

load max(Month) as MaxDate

Resident DATA

where len(xSales)<>0

Order by Month desc;

Let vMaxDate=peek('MaxDate',0,'SalesDate');