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: 
ZoeM
Specialist
Specialist

Setting conditional expression using Today()

Hi Community.

I have a chart with 6 expressions and I would like to set one expression to only calculate on a condition that the selected Year in the List box equals current year. If the selected year is either greater than or less current year, then it wont calculate.

My conditional expression:

GetCurrentSelections(Year)= Date(Today(),'YYYY') 

But I am not getting any results.

any help with getting the right syntax for the expression will be truly appreciated.

1 Solution

Accepted Solutions
sunny_talwar

Hahahaha, you are right... you should be using GetFieldSelections(Year) instead of GetCurrentSelections 🙂

View solution in original post

10 Replies
sunny_talwar

I am guessing that you year field is created like this in the script

Year(DateField) as Year

May be try this

GetCurrentSelections(Year) = Year(Today())
ZoeM
Specialist
Specialist
Author

Thanks for responding,

No, my year is not set up that way in the script.

I tried your suggestion but I got no results...

sunny_talwar

How do you create a year field in the script?
ZoeM
Specialist
Specialist
Author

I have a Date Key which works with the Master Calendar.

sunny_talwar

Make sense, but how is Year field created?
ZoeM
Specialist
Specialist
Author

Below are my date fields:

LOAD %Date,
Date,
Year,
[Quarter Number],
[Quarter Name],
[Month of Year],
[Month of Year Name],
[Month of Year Abbreviated Name],
[Week of Year],
[Day of Week],
[Day of Week Name],
[Day of Week Abbreviated Name],
[Day of Month],
[Day of Year],
[Days in Month],
Date(MonthStart(Date),'MMM YY') as YearMonth,
[Leap Year Flag],
[Weekend Flag],
[Production Month],
[Production Year],
[Issue Number],
[Julian Date],
[Week Ending Friday]

sunny_talwar

Can you try this

LOAD %Date,
Date,
Year(Date) as Year,
[Quarter Number],
[Quarter Name],

and then this

GetCurrentSelections(Year) = Year(Today())
ZoeM
Specialist
Specialist
Author

Chart1.JPGChart2.JPG

 

Still I get nothing. It should be GetCurrentSelections right?

sunny_talwar

Hahahaha, you are right... you should be using GetFieldSelections(Year) instead of GetCurrentSelections 🙂