There are a few ways to do this. Each with their own pros and cons.
Let’s start by examining a dashboard that is not filtering by the current user. This dashboard is simple and contains 10 features.
Starting Dashboard with 10 Features
Pros:
Cons:
Requirements: A field in your dataset containing the username you want to filter data by.
Assigned User Field
From the layer’s Item Details page, select Create view layer > View layer.
Create View Layer
Expand the Layer definitions section and add a filter.
Select the field that contains the username you will be filtering by and change the operator to ‘is current user’.
View Layer Definition
Finish creating the view.
Let’s look at our resulting data.
Layer with 5 features - all assigned to me
I can only see records that I am assigned to. If another user was to look at this view, they would only see the records that are assigned to them.
This new view layer will be used to create our dashboard.
Dashboard with 5 features
Pros:
Cons:
Requirements: A field containing a comma separated list of usernames to filter.
Field with comma separated users.
My fabulous colleague @PaytenJarnagin has already outlined all the steps, so I won’t rehash them here. Go check out Display Features Relevant to the Current User for step by step instructions.
Here is the result of the view.
Layer with 6 features - all of which include my username.
Again, we can use this new view layer as our dashboard source.
Filtered dashboard with 6 features.
Pros:
Cons:
Requirements: A layer that will be used as a look up table.
Let’s look at our starting dashboard. This time I’m using the USA Current Wildfires layer from the Living Atlas.
USA Wildfires Dashboard
The wildfire layer contains a field indicating the Point of Origin State. I’m going to create a look up table that assigns users to a specific Point of Origin state.
Look up table with the assigned username and assigned state.
The state value is going to be used to filter the wildfire data, so it must match the values in the Current Wildfire layer. The assigned user field will include the username of the person assigned to that state.
In my dashboard, I’m going to add a Category Selector that uses Categories from Features.
The data source will be a Data Expression that filters my look-up table based on the current user.
// Look Up Table
var fset_incidents = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
'4ec710cb554d40999d240bc39a04c9b0',
0
)
var username = GetUser()['username']
return Filter(fset_incidents, `assigned_user = '${username}'`)
I’m including both the state and user in my template, but you can use whatever makes sense for your use case.
Category Selector Configuration
Make sure you do NOT enable the ‘None option’ for your selector.
Finally, I will set it to filter all of my dashboard elements based on the State field.
Category Selector Actions
Here is the final dashboard.
Wildfire dashboard showing only California wildfires.
Design your dashboard with the full dataset. Based on the assignments, you may not have any records in the resulting view layers. Designing dashboards with empty or limited data is challenging and difficult to fully test. I always create the dashboard with the full dataset. Once I have the design locked, I create a copy of the dashboard and use the views in the dashboard copy.
Check out the rest of the series for more dashboard tips: Dashboards That Pop.
Happy Dashboarding!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.