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

Calender with the help of varaibles help ?????

Hi Folks,

I'm having two variables named as vStartDate and vEndDate ,these two variables I'm calling in many expressions inside a pivot table , so that whenever a user set some value against Period From and Period To , pivot table will change according to the date range selection.

Period From: vStartDate

Period To : vEndDate

Mentioned below is an expression example named Available time where I'm using both these two variables:

Available Time: =sum(aggr(

sum( {<PRI_CALENDAR_END={">=$(vStartDate)"}, PRI_CALENDAR_START={"<=$(vEndDate)"}>}

Interval( if( PRI_CALENDAR_END > vEndDate, vEndDate, PRI_CALENDAR_END ) - if( PRI_CALENDAR_START < vStartDate, vStartDate, PRI_CALENDAR_START ) )

), SLINIENR, SMASCHGRPNR, SMASCHNR, SMASCHTYPBEZ) )

Like Available time there are some 9-10 calculated pivot table expression where I'm using both these two variables.

Requirement:   I want to create a simple calender with the help of these two variables (vStartDate & vEndDate) , something like below:

Kindly help me how to reach to this kind of solution.

Thanks,

AS

11 Replies
amit_saini
Master III
Master III
Author

Folks please help me on this.

Thanks,

AS

SunilChauhan
Champion
Champion

hic
Former Employee
Former Employee

I would not use variables for that type of user interactions. Variables are not user-friendly.

Instead, I would create a calendar in the script, e.g.

     Let vStartDate = 41000;

     Let vEndDate = 42000;

     Calendar:

     Load *,

            Month(Date) as Month,

            Year(Date) as Year;

     Load Date(RecNo()+$(vStartDate)-1) as Date

            Autogenerate vEndDate - vStartDate + 1;

and then let the user make the selection in your calendar fields. You can then use Max(Date) and Min(Date) in your expressions to dynamically find the selected range.

HIC

amit_saini
Master III
Master III
Author

Hi Henric,

Thanks for your suggestion , I strongly agree with you but I have to work further on this application created by someone else. The only option available  for me to play around with these two  variables in order to create user friendly calender as mentioned in my above post.

Thanks,

AS

amit_saini
Master III
Master III
Author

Henric,

Also here instead of one single Date filed as you mentioned in your solution I'm having around 9-10 Date fields , the question is how to link all of them together to vStartDate and vEndDate variable.

Please suggest any solution on this.

Thanks,

AS

tresesco
MVP
MVP

May be like attached?

amit_saini
Master III
Master III
Author

Tresesco,

This Calender I have already created by using variables , main concern is how to create Year, Month ,Day kind of options from these variables . See below

In general the way we are creating is Year(Date) as Year and same for Month and Day, but here how play with varibles for such solution.

tresesco
MVP
MVP

Amit,

It's bit complex in the front-end. But possible, see my attachment. You might have to work on it further.

amit_saini
Master III
Master III
Author

Tresesco,

Here in your mentioned example selection depends upon variables, I want it other way user should be able to select any year , month and day here in current scenario depending upon variables value we are getting Year and Month.

I'm sorry I'm not sure whether this is possible or not through Front end . But Thanks for your suggestion.

Thanks,
AS