
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
$ sign expansion for dates
I have a simple table with 3 columns:
Date 1 containing dates
Date 2 containing different dates
ChosenDate containing either the value Date1 or Date 2.
For each record I would like to see a field called NewDate which is either Date1 or Date2 depending on the value in ChosenDate. Currently I tried $(ChosenDate) as NewDate but no luck. Any suggestions?
- « Previous Replies
-
- 1
- 2
- Next Replies »


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you trying to do this in the script or in a chart?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this, I think it meets your need.
Pick(Match([ChosenDate],'Date1', 'Date2') ,[Date 1], [Date 2]) sa NewField
Qlik Community MVP


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would think
[$(ChosenDate)] as NewDate
would do it. What error/problem are you getting when you use that in script?
-Rob

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the suggestion - it doesn't work however. The following error messages comes up:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[$(=ChosenDate)] as NewDate
Qlik Community MVP


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, I just reread the original post. I see know we are talking about fields and varying per row. Try this.
if(ChosenDate = 'Date1', Date1, Date2) as NewDate
-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks both - unfortunately with the new dollar expansion I get the same error message. The if statement or alternative the pick(match()) both work but aren't ideal as actually I have Date1, ..., Date 20 not just 2 dates and so I was hoping to avoid a large nested if statement or a large pick match statement....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For _type=1 to 20
Load
...
[Date $(_type)] as NewDate
FROM source
Where
ChosenDate = 'Date $(_type)'
Next
It might not be an better approach than the ones mentioned above, but you will get rid of the nested IF.
Qlik Community MVP

- « Previous Replies
-
- 1
- 2
- Next Replies »