Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I'm trying to lookup a field value based on a user selection, I am using Lookup() , but I'm guessing I'm doing something incorrect as I cannot see this working.
This is being used outside the context of a load, hence am I working outside the scope of this function requirement , I am trying to set the variable dynamically , see below...
=if(max(CalendarDate) = lookup('CurrentTo', '[Country Code]', GetFieldSelections([Country Code]) , 'DateNow'),1,0)
Thanks in advance
Paul
Hi, It will never work, lookup is a script function only, you'll need to think of a different way.
Hi, It will never work, lookup is a script function only, you'll need to think of a different way.
Returns the value of fieldname corresponding to the first occurrence of the value matchfieldvalue in the fieldmatchfieldname.
Fieldname, matchfieldname and tablename must be given as strings (e.g. quoted literals).
The search order is load order unless the table is the result of complex operations such as joins, in which case the order is not well defined.
Both fieldname and matchfieldname must be fields in the same table, specified by tablename. If tablename is omitted the current table is assumed.
If no match is found, null is returned.
I occasionally have issues using this function - mainly as I try to avoid it anyway. Couple of things from trial and error:
Hey Paul,
Can you provide a little more details.
A sample file would also be very helpful.
Also as mentioned by Steve Lookup() can't be used on the Front-end.
Thanks
AJ
Correct, Yes I found another way where I could avoid a lookup completely.
Thanks
Hi Paul,
It would be great if you could tell me what is the way to write the expression. I'm facing the same issue
Hi Paul,
I've had similar situations and ended using the Only() function:
e.g.
I needed to find the year from my MasterCalandar based on yesterdays date:
=only({<DateID={'$(=num(today())-1)'}>}[Acct Year])
So you can see that I'm returning [Acct Year] where my DateID is yesterday.
I'm sure you can adapt this quite easily to suit your needs?
Cheers
Chris
Thanks for the pointer Chris,
I have a little table with NTNAME and Employee_Country, and used the following variables to detect Country of current user, so I could use in a show hide expression on a set of tables, where users in certain countries can only see certain columns.
v_OSUSER = OSUser() ;
v_User_Country = only({<NTNAME={'$(=$(v_OSUSER))'}>}EMPLOYEE_COUNTRY) ;
Show hide condition = If ( Match(Upper($(v_User_Country)),'XXX','YYY')>0,1,0)
Regards Greenee