Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
durgabhavani
Creator III
Creator III

How to restrict values in list box?

Hi All,

I have dates for ten years in my calender object. (I am using date field from database in calender object)

But i don't want to display all 10 years values in calender. I need to display just latest year (2015) values in my calender.

(date format in my calender: mm/dd/yyyy.)

Please advice!

Thanks,

Durga

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

Insted of selecting a Field in the Field drop-down select <Expression> and then use the following expression:

=If( Year ( Date ) = 2015 , Date )

See below:

2015-04-27 #3.PNG

View solution in original post

10 Replies
sunny_talwar

Use an expression instead of list box field: Only({<Date = {"=Year(Date) = 2015"}>} Date)

Best,

Sunny

durgabhavani
Creator III
Creator III
Author

Thanks for response Sunny!

If i want to restrict values in calender then what to do?

Durga

sunny_talwar

Do you mean in the script itself? or are you talking about a calendar object?

petter
Partner - Champion III
Partner - Champion III

Insted of selecting a Field in the Field drop-down select <Expression> and then use the following expression:

=If( Year ( Date ) = 2015 , Date )

See below:

2015-04-27 #3.PNG

sunny_talwar

Petter do you know why the Only function isn't working here??? Is there a way to solve this with a set analysis??

Best,

Sunny

durgabhavani
Creator III
Creator III
Author

Anyway sunny,

I want to restrict my dates for this year only. Either in script or directly in calender object!

Thanks,

Durga

sunny_talwar

In the script you can use a where statement like this:

LOAD yourFields,

          Date

FROM xyz

Where Year(Date) = 2015;

On the front end you can use Petter Skjolden‌ for both the list box as well as calendar object. They both give you the ability to enter expression instead of using a field name directly.

Use this expression: =If( Year ( Date ) = 2015 , Date ) give by Petter.

HTH

Best,

Sunny

kashporov
Partner - Contributor
Partner - Contributor

Use this expression in List Box:

=aggr(distinct Only({<DateField={">$(=MakeDate(2015))"}>}DateField),DateField)

durgabhavani
Creator III
Creator III
Author

Super sunny!

i thought only for listbox has the facility of expression. but i found expression in calender object and it works as well.

Thanks Petter!

Durga