Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
piotr-bratek
Contributor III
Contributor III

Derived fields - $1 meaning & AutoCalendar

Hi Guys,

two questions:

1. Can you pls give me any other real-life, valuable example of using DERIVE & DECLARE instructions than AutoCalendar scenario?

2. I'm testing DERIVED and DECLARE instructions, reading Help but can't really get the idea of this 'referenced field'. Help says:

Use $1 to reference the data field from which the derived fields should be generated.

Example:  

Year($1) As Year tagged '$year'

I've tested a typical scenario with AutoCalendar and 4 dates:

DERIVE FIELDS FROM FIELDS [OrderDate], [Date], [RequiredDate], [DeliveryDate] USING [autoCalendar] ;

Is there any reason to change $1 to $2? Is there any other case which works and makes sense?

Scenario 1 - using $1

ac1.png

Scenario 2 - using $2

ac2.png

Many Thanks!

 

ex-Training Manager at Qlik Central-Eastern Europe
Labels (4)
2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

$1 is simply a placeholder for the field being processed.  In your posted example, all fields tagged with '$date' will get processed. If the current field is 'OrderDate', the $1 gets substituted in the script and you have:

Year(OrderDate) As Year tagged '$year'

No, it does not make sense in this example to ever use $2.

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

piotr-bratek
Contributor III
Contributor III
Author

Thanks Rob! That makes it clear. What about Question 1? I know I could find some potential scenarios, but out of curiosity 🙂 - have you ever applied this method to create some derived dimensions other than dates ?
ex-Training Manager at Qlik Central-Eastern Europe