Filtering dashboard data by "Today" along side grouping on other fields

493
2
05-22-2023 04:25 AM
Labels (1)
WilliamMcIntosh1
New Contributor

Hi

There are a number of date related questions and solutions on this forum, but none that I can get to work in my situation. 

I have a dataset with capacities (of water) transported to certain locations and the date it was transported there in timestamp format. I want to show a list item showing the amount of water transported to each location TODAY.

I have the data grouped by location to get the total amount of water at each location. via the following:

Var fs = Filter(FeatureSetByPortalItem(Portal('https://[agol]/'), '[item ID]', 0), "Fill_Empty = 'Fill'")

return GroupBy(fs, ['location'], [
  {name:  'Vol. Water', expression: 'capacity', statistic: 'SUM'},
  {name:  'Loads', expression: 'Tanker_ID', statistic: 'COUNT'}
]);

My problem comes when I try to show how much water was transported today! I cant use the filter by date as I obviously can't group dates without upsetting the above.

I hope this is clear enough, hard to explain a problem to someone who does not know the dataset.

Can anyone suggest a solution please?

Tags (3)
0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

To filter by date, the date needs to be present in the grouping fields list. Where are you implementing this, though? Lots of Dashboard widgets can handle the grouping for you, and you could show statistics per-date straight from the feature layer, no need for an expression.

- Josh Carlson
Kendall County GIS
WilliamMcIntosh1
New Contributor

Sorry for not replying sooner, thanks for your answer. Typically, 10 mind after I asked this question I cracked it.

I was using a list item to display some grouped attributes (total amount of water delivered to a site) but I needed to only filter results for today. 

the final code I went with was the following;


 

var datefield = FeatureSetByPortalItem(Portal('https://[Orgaisation].maps.arcgis.com/'), '[item ID]', [Layer ID], ['Tanker_ID', 'Fill_Empty', 'Time', 'Location', 'Capacity'],False);
var fsfilter = Filter(datefield, "Fill_Empty = 'Fill'")
var fstoday = Filter(fsfilter, "Time >= CURRENT_DATE")

 

0 Kudos