Without having an equivalent lookup to play with, I found a couple syntax issues with the first part of search you wrote. Can you give this a try to see if this produces the same table as your first screen shot?
| inputlookup hierarchy_lookup.csv
| where
[| rest /services/authentication/current-context
| where username!="splunk-system-user"
| rename username as EnterpriseID
| table EnterpriseID
| format]
| fields Scope, Module, EnterpriseID
| join Scope, Module type=inner
[| inputlookup hierarchy_lookup.csv
| stats count by Scope,Module]
As for the second part, the request is to have a table automatically display the same scope and model for all users that share the Scope and Module as that user. I believe the below search would accomplish that to produce the table you listed out:
| inputlookup hierarchy_lookup.csv
| where
[| inputlookup hierarchy_lookup.csv
| where
[| rest /services/authentication/current-context
| where username!="splunk-system-user"
| rename username as EnterpriseID
| table EnterpriseID
| format]
| table Scope Module
| format]
| fields Scope, Module, EnterpriseID
| join Scope, Module, EnterpriseID type=inner
[| inputlookup hierarchy_lookup.csv
| stats count by Scope Module EnterpriseID]
... View more