Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
thomasreynaert
New Contributor III

Using slider to set a variable

Hello everyone

I have a slider that is set up to act as a period selector.

Min value and max value are defined as follows 

'=date#(min({1} date_YYYYMM),'YYYYMM')'

'=date#(max({1} date_YYYYMM),'YYYYMM')'

Slider.PNG

I use these periods in my set analysis, for example:

Count({$<[order_date_YYYYMM]={">=$(=min(date($(vPeriod3),'YYYYMM')))<=$(=max(date($(vPeriod4),'YYYYMM')))"} ,$(vExp_Unselect_datefields), $(vExternalClients),$(vOnlyBOWithKnownLT),$(vExcludingArticleTypes)>} so_ordernumber)

Now I face 2 problems:

1. When sliding up & down my 12 month selection seems to have 12 or 13 months. Probably the period is somewhere between 12 and 13 months, where I would like to have exactly 12. I thought that having static step would prevent this.

2. My variable vPeriod3/4 often becomes a value with digits for example 42890,4. This causes my calculations to be wrong.

14 Replies
MVP & Luminary
MVP & Luminary

Re: Using slider to set a variable

A value of 42890,4 means that you haven't a date else it's a timestamp. You could with:

date(floor([order_date_YYYYMM])) as [order_date_YYYYMM]

transform your timestamp into a date. And quite probably I would do it directly within the script and not just within the mentioned variables/expressions.

- Marcus

thomasreynaert
New Contributor III

Re: Using slider to set a variable

These are all dates, no time stamps.

Date Table.PNG

Thanks for your help!

MVP & Luminary
MVP & Luminary

Re: Using slider to set a variable

To see a date doesn't mean mandatory that it is really a date - it could be just formatted. And 42890,4 is definitely a timestamp - just use in a textbox: timestamp(42890.4) to see the result.

- Marcus

thomasreynaert
New Contributor III

Re: Using slider to set a variable

Indeed but there is no formatting set to date. In fact if the choice is made to display decimals, it will display ,00. Also the source data is only a date, no time-stamp.

MVP & Luminary
MVP & Luminary

Re: Using slider to set a variable

How are your variables vPeriod3/4 created?

thomasreynaert
New Contributor III

Re: Using slider to set a variable

Well they are dynamic, since the user can drag the slider and thereby changing the variables.

MVP & Luminary
MVP & Luminary

Re: Using slider to set a variable

I think your min/max isn't like you expected it - just try them within a textbox:

=date#(min({1} date_YYYYMM),'YYYYMM')'

=date#(max({1} date_YYYYMM),'YYYYMM')'

and think it should be rather like:

floor(min({1} date_YYYYMM)) // maybe without a formatting

- Marcus

thomasreynaert
New Contributor III

Re: Using slider to set a variable

Both formulas will give me 201501 or 201712 respectively as expected. These variables are used to define the start and end of the slider. The problem is the bar that defines the periods.

Current.PNG

Thanks for your perseverance

MVP & Luminary
MVP & Luminary

Re: Using slider to set a variable

What returned min/max({1} date_YYYYMM) within a textbox by different selections? Always an integer?