Skip to main content
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
thomasreynaert
Contributor III
Contributor III
Author

Well if I would leave the formula like it is, the result won't change based on selection.

With min/max({$} date_YYYYMM), the result will change. However still always as integer

marcus_sommer

If I look again on your slider I'm not sure if a date is really suitable to create a slider with 12 month between min and max. Months and even years are not homogenous over a longer period and therefore the selected range might not always fit exactly. I could imagine that a period-field is more suitable.

- Marcus

thomasreynaert
Contributor III
Contributor III
Author

I'm not sure if I understand correctly. The fields that I use are link_date_YYYYMM, I don't see how any other date field could change the problem. For example I could use link_date with all the dates, but that will give the same range except that I need the user to select by month. 

thomasreynaert
Contributor III
Contributor III
Author

I found a solution to my 2nd problem.

Apparently setting static step to '2' instead of '1' seems to avoid decimals appearing. I believe setting it to 1 would also do the job.

My 1st problem remains, in fact QV gives me a lower granularity than I need. I just need 36 monts (2015-2017) instead of 1096 days.

marcus_sommer

This is what I mentioned above that a daily level won't be homogenous enough to select a period of 12 months over several years. But you could use a period-field for it mayve created within the master-calendar with something like this:

(year(Date) - 2000) * 100 + month(Date)

or

dual(date(Date, 'YYMM'), autonumber(year(Date) & '|' & month(Date)))

- Marcus