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: 
thomasreynaert
Contributor III
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
marcus_sommer

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
Contributor III
Contributor III
Author

These are all dates, no time stamps.

Date Table.PNG

Thanks for your help!

marcus_sommer

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
Contributor III
Contributor III
Author

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.

marcus_sommer

How are your variables vPeriod3/4 created?

thomasreynaert
Contributor III
Contributor III
Author

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

marcus_sommer

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
Contributor III
Contributor III
Author

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

marcus_sommer

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