Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create a filter for year, month, week, day of same field in listbox

Hi,

I have a field OrderDate which has the date values. I would like to create a filter where user can select either a year, quarter, month, week, day which should be displayed in listbox and on click of each value the corresponding OrderDate should change.

Please let me know if anyone has faced such situation.

Thanks,

Sai

10 Replies
danieloberbilli
Specialist II
Specialist II

Do you mean sth in the way: if the user clicks a month value in the month-listbox, then the dimension of your chart object should switch to Month? Else the dimension should switch to day if the user selects a day-value?

Not applicable
Author

filter.PNG

This should be the output. The field name is OrderDate but i wanted to display in list box as day, month, quarter, year.

If user clicks day, the day in orderdate should be filtered and so on.

Not applicable
Author

Hi Sai,

If I understand correctly you will need to add some additional logic to your load script to break the date into the various components of Year, Month and Day.

A lot has been written in this Community on the best way of achieving this eg Calendars, etc, however a very quick and simple way is to add something like the following:

Year(OrderDate) as Year,

Month(OrderDate) as Month,

Day(OrderDate) as Day

Once the script has been reloaded you will have these three new fields and you can add these fields onto your sheet.

Hope this helps.

Kind regards,

Rod

Not applicable
Author

Hi Rod,

Thanks for your response.

Your suggestion will create 3 different fields which I am not looking for. The alternate for which you have mentioned is List Box Expression where I can write the same thing and eliminate additional columns, Reload mechanism.

The answer I am looking is to create a field like #orderdate which has value year, month, week, day that relates to the orderdate.

Hope you got my requirement.

Thanks,

Sai

danieloberbilli
Specialist II
Specialist II

I still don't get it. Imagine you have the following OrderDates:

02/03/2014

05/03/2014

10/05/2014

so now you click on a value called 'Day'...what do you want Qlik actually to filter/to show?

Not applicable
Author

Hi Sai,

Maybe look into setting the field up as a hierarchy, I think this will give you something close to what you want eg you can select a year then expand to a month then a day.

I have used that logic in a few applications, not for dates though, but where I need the ability to filter at different levels but present the data as a single dimension.

Kind regards,

Rod

Not applicable
Author

Hi Daniel,

As you could see on the above image, the list box contains data as "year","month","week","day" but not the real dates like

02/03/2014

05/03/2014

10/05/2014

I have some other charts where I am using the expression as Year(Orderdate), Month(OrderDate) and so on. So, when you click on the day, it will display day related charts.

danieloberbilli
Specialist II
Specialist II

Sorry Sai, I might be still confused with "it will display day related charts":

You could create a field e.g. by inline load like

Field: OrderDate_Element

Values: Day, Month, Year

-> If the user selects the value 'Day' of the Field OrderDate_Element you could use this as a show condition for the whole chart object or for a single expression or dimension like     GetFieldSelections(OrderDate_Element)='Day'  >true will show the chart ,false will hide the chart

Is this what you want?

demonioazul
Creator
Creator

Thanks, for me this was the solution I was looking for!