Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
coleturegroup
Contributor III
Contributor III

How can I accomplish an Applymap Call like function while on a sheet or chart?

Question: How can I accomplish an Applymap Call like function while on a sheet or chart?
 
GET THE CURRENT USERID AND PASS IT ALONG:
Currently in the LOAD SCRIPT CODE:
 
LET vUser=right(OSUser(),8);
 
Map_UserID:
Mapping LOAD
"EmpUserID",
    BUSINESSUNIT    
FROM [lib://XXXXXX/YYYYY/Employee.qvd](qvd);
 
// Note: THIS BELOW SETS IT TO THE RESOURCE WHO PERFORMS THE LOAD REFRESH:
// The Where clause seen below works to the Applymap call to complete getting the user region. 
 
[Emp Hours]:
LOAD  *
FROM [lib:///XXXXXX/YYYYY/EmpHours.qvd]
(qvd)
Where RegionBU = Applymap('Map_UserID','$(vUser)') 
// Usually returns SysAdminBU unless I personally reload it
;
 
 
NOW ON THE SHEET: I need to retrieve the current user logged onto the App/sheet:
 
I ADDED AN ACTION to the sheet:
Set Variable Value: TO
vUser
Value: TO
=right(OSUser(),8)
 
How do I get this current Users  BUSINESSUNIT?
 
Thanks in advance, this is a puzzler...
Labels (4)
1 Solution

Accepted Solutions
marcus_sommer

I think a normal set analysis may also return the wanted result, maybe:

only({< EmpUserID = {"$(=right(osuser(), 8))"}>} BUSINESSUNIT)

View solution in original post

6 Replies
marcus_sommer

If you load the User-BU mapping a second time as a normal (distinct) table you could query the information - either directly to the field if there is only a single record when if the same where-condition could be applied or by multiple values with an expression like:

fieldvalue('BUSINESSUNIT', fieldindex('EmpUserID', right(osuser(), 8)))

coleturegroup
Contributor III
Contributor III
Author

 load the User-BU mapping a second time as a normal (distinct) table you could query the information. Are you talking about a partial reload?

seanbruton

Hi @coleturegroup 

Appymap and its partner Mapping Tables only is active while loadscript is running. When the script ends then all Mapping tables are dropped for optimization reasons so indexing is also completed.

That is important for consideration on scripting planning as you can drop tables anytime, but a MAPPING table is always there until the end. Larger mapping tables does affect performance as well.

I hope this helps.

 

marcus_sommer

No, it hasn't any relation to partial/incremental measurements else just loading the data into the data-model. 

coleturegroup
Contributor III
Contributor III
Author

Marcus, when I execute the fieldindex function with my ID for example returns the number 1000 which when feed it to the fieldvalue function returns NULL.

We have 1040 distinct ID's tied to 22 BU's in the distinct load table. I think that is why it returns a Null. 

Any ideas?

marcus_sommer

I think a normal set analysis may also return the wanted result, maybe:

only({< EmpUserID = {"$(=right(osuser(), 8))"}>} BUSINESSUNIT)