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

Assigning Date based on user selection

Hello Community,

I have a scenario,where user wants to show the data of previous day. However if he selects the date from then the related days data should appear.

I tried in this manner.

if(isnull(CSD.dtmDate),Date(Today()-1,'DD-MM-YYYY'),Date(GetFieldSelections(CSD.dtmDate),'DD-MM-YYYY'))

Here I was succeeded up to assign the previous day value and the user selected values to Date.

I am unable to assign the same to CSD.dtmDate.

Help me to succeed.

Thnx a lot.

Sudhir.

1 Solution

Accepted Solutions
Or
MVP
MVP

You can go about this in several ways, depending on your specific requirements:

1) Force a selection of the date field, combined with OnOpen triggers: select a single date, enter the list box properties, and check "Always one selected". Enter the document properties, select Triggers, and create an OnOpen trigger where the field is your date field and the value is =Today()-1 . This will automatically select yesterday, and force a single date to be selected at all times, displaying values for that date. It is relevant if you always want a specific date selected.

2) OnOpen trigger - use the latter part of the above to pre-select Today()-1. This will allow users to select any date range they want, but it will also allow them to clear the date selection entirely.

3) Set analysis - in this case, you will need a formula similar to what Sunny T describes in the original reply. Alternatively, you can create a script-level flag in your data based on the formula:

If(Date=Today()-1,1) as YesterdayFlag

In this case, your formula would be something like:

If(GetSelectedCount(Date)=0,Value*YesterdayFlag,Value)

Which would only display yesterday's values unless something - anything - was selected in the Date field.

Hope at least one of these helps..

View solution in original post

5 Replies
sunny_talwar

I guess you are planning to use this in set analysis right? Try this:

=If(GetSelectedCount(CSD.dtmDate) = 0, Date(Today() - 1, 'DD-MM-YYYY'), Concat(DISTINCT Chr(39) & Date(CSD.dtmDate, 'DD-MM-YYYY') & Chr(39), ', '))

sudhir0538
Creator
Creator
Author

this is the layout of my document upon opening.

1.JPG

But My requirement is like this

(Assume today is 22-08-2016, then the previous day 21-08-2016 data should be populated automatically upon opening of the document,However,user will have the provision to choose the date according to his will )

1.JPG

Sunny Yours idea is working but it's not making the date field to be auto select the previous day date.

sunny_talwar

I think you are looking to get OnOpen Trigger. See if the link helps:

Adding Default Selections in QlikView - The QGate Knowledgebase

Or
MVP
MVP

You can go about this in several ways, depending on your specific requirements:

1) Force a selection of the date field, combined with OnOpen triggers: select a single date, enter the list box properties, and check "Always one selected". Enter the document properties, select Triggers, and create an OnOpen trigger where the field is your date field and the value is =Today()-1 . This will automatically select yesterday, and force a single date to be selected at all times, displaying values for that date. It is relevant if you always want a specific date selected.

2) OnOpen trigger - use the latter part of the above to pre-select Today()-1. This will allow users to select any date range they want, but it will also allow them to clear the date selection entirely.

3) Set analysis - in this case, you will need a formula similar to what Sunny T describes in the original reply. Alternatively, you can create a script-level flag in your data based on the formula:

If(Date=Today()-1,1) as YesterdayFlag

In this case, your formula would be something like:

If(GetSelectedCount(Date)=0,Value*YesterdayFlag,Value)

Which would only display yesterday's values unless something - anything - was selected in the Date field.

Hope at least one of these helps..

sudhir0538
Creator
Creator
Author

hello guys..

Thanx a lot for the help. But lemme tell you nothing has been worked as of now in my application.I don't know what'll be the reason.