It looks like that inside the data expression editor of my sample ArcGIS Dashboard the "Globals" are missing
(as described in this video: https://www.youtube.com/watch?v=Dub1Ako2ljw&t=1008s😞
Is there any setting or somethings else to get it?
Thanks and regards,
Daniel.
Hi @XanderBakker,
thanks again.
> I would recommend you to reach out to support and create a case to discover the reason why this is not working.
That's the way I will follow.
Thanks in the meantime and regards,
Hi @dstrigl ,
I have no idea how the data was published and from what format, but I am glad that the test you performed shows that it does work (for the test dataset). This confirms that the issue is data-related. I would recommend you to reach out to support and create a case to discover the reason why this is not working. The fact that you are using ArcGIS Online helps since you automatically always have access to the latest version.
thanks again for your help. You are right, it must be the data itself which causes the problems!
I am currently working with ArcGIS Online.
Now I created a complete new Feature Layer with a Feature Class including some domains with ArcGIS Pro.
I added some sample data and published it to ArcGIS Online.
And with this data the request of the domain names inside a data expression works!
Do you have any idea what causes the problem with the other data?
Regards,
I think this is caused by GroupBy function which will take the values of the account managers and not the descriptions. There are different ways to resolve this, but below you can see how you can create an intermediate dictionary and harvest the values that you need and write the result after this.
var p = Portal('https://www.arcgis.com'); var itemId = '???'; var layerId = 1; var fs = Filter(FeatureSetByPortalItem(p, itemId, layerId, ['ACCOUNT_MANAGER', 'REGION'], false), 'ACCOUNT_MANAGER > 0'); var dict = { 'fields': [ { 'name': 'ACCOUNT_MANAGER', 'type': 'esriFieldTypeString' }, { 'name': 'COUNT_REGIONS', 'type': 'esriFieldTypeInteger' }], 'geometryType': '', 'features': [] }; // create an intermediate dictionary // to store a list of unique regions per account manager var d = {}; var l = []; for (var f in fs) { var accman = DomainName(f, 'ACCOUNT_MANAGER'); var region = f["REGION"]; if (HasKey(d, accman)) { l = d[accman]; Insert(l, 0, region); } else { l = [region]; } d[accman] = Distinct(l); } // write the dictionary to the output featureset var index = 0; for (var accman in d) { dict.features[index] = { 'attributes': {'ACCOUNT_MANAGER': accman, 'COUNT_REGIONS': Count(d[accman]), }, } index++; }; return FeatureSet(Text(dict));
thanks a lot for your hints!
> However, it might be easier to create the field with the domain description rather than the domain code for visualization purposes.
That's exactly what I am trying now ... something like that (using the function DomainName):
var portal = Portal('https://www.arcgis.com'); var itemId = '???'; var layerId = 1; var fs = GroupBy( Filter( FeatureSetByPortalItem(portal, itemId, layerId, ['ACCOUNT_MANAGER', 'REGION'], false), 'ACCOUNT_MANAGER > 0'), ['ACCOUNT_MANAGER'], [ { name: 'COUNT_REGIONS', expression: 'REGION', statistic: 'COUNT' }, ]); var dict = { 'fields': [ { 'name': 'ACCOUNT_MANAGER', 'type': 'esriFieldTypeString' }, { 'name': 'COUNT_REGIONS', 'type': 'esriFieldTypeInteger' }, ], 'geometryType': '', 'features': [] }; var index = 0; for (var f in fs) { dict.features[index] = { 'attributes': { 'ACCOUNT_MANAGER': DomainName(f, 'ACCOUNT_MANAGER'), 'COUNT_REGIONS': f['COUNT_REGIONS'], }, }; index++; } return FeatureSet(Text(dict));
Is that the way you recommend, because it doesn't seem to work in my sample ...
But there is one additionally thing I found out. If I try the following:
var fs = FeatureSetByPortalItem(...); Console("ACCOUNT_MANAGER:"); for (var f in fs) { var d = DomainName(f, "ACCOUNT_MANAGER"); Console(d); }
I only get the numeric values and NOT the names represented by the domain!
ACCOUNT_MANAGER: 4 2 2 4 4 . . .
You have any idea why I didn't get the correct domain names?
The names are still in the layer, because if I open the table inside the Map Viewer I will see it ...
Some note: Could it be a problem that the table which includes the ACCOUNT_MANAGER has a subtype?
Just a little note; since you create a FeatureSet you could include the domain definition in the creation process. However, it might be easier to create the field with the domain description rather than the domain code for visualization purposes.
Thanks a lot @Anonymous User
I'm a novice when it comes to data expressions and arcade expressions. Slowly improving! My latest post is linked below, so hopefully my script can help you build yours! https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-for-pie-chart-in-dashboard-fails/m-p/1096039#M5033@XanderBakker is an excellent resource for Arcade and Data Expressions. I'd highly recommend reviewing his posts and answers for more tips!
Thanks for the info and the link!
I found the way of using FeatureSetbyPortal which works fine, but this means that's not possible to directly access the features of a allready included map of the dashboard.
I have to access it using FeatureSetbyPortal. It's ok for me, but doesn't really make sense for me why it's not possible to reference it using globals vars.
Another question: Have you ever created FeatureSets using data expression with domains?
I have the problem, that if I create a new FeatureSet with the data expressions from a FeatureSet which allready have a relation to a domain this git lost 😞 ...
Globals are not available in Data Expression. You have to use FeatureSetbyPortal. I'm struggling with data expressions myself.https://www.esri.com/arcgis-blog/products/ops-dashboard/announcements/introducing-data-expressions-in-arcgis-dashboards/
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.