Select to view content in your preferred language

Exclude categories from the table widget when status/data for those categories change

666
1
07-28-2023 09:24 AM
Labels (1)
Shubhreet
Regular Contributor

Hello,

I am trying to create a sample dashboard for outbreak status ('yes' or 'no') within the Personal Care Homes (PCHs). Sample scenario is: There are in total 13 PCHs that have reported outbreak so far via Survey123 but out of these 13 PCHs 2 of them have recently closed their status on outbreak (by choosing 'no' through Survey123).

I would like to add a table widget in the dashboard that will include all PCHs currently in outbreak. The current table widget setting shows a list of all PCHs (13) that have reported outbreak so far which also includes the one that are no longer in outbreak (2 PCHs). Is there a way I can remove those 2 PCHs from the table widget?  These 2 PCHs may need to be included again if in future they declare any outbreak. 

I tried a lot of ways: using filters and advanced formatting  - but no luck. Even if I use filter, it does not change anything since for the PCHs which are now not in outbreak were once declared with outbreak and those records are still stored in the feature layer which could not be filtered out based on the second screenshot below. 

 

Shubhreet_0-1690561084056.png

Shubhreet_1-1690561177064.png

 

 

I spent lots of time figuring this out. Any assistance/modification/idea would be of great help to me. 

1 Reply
Shubhreet
Regular Contributor

Hello, 

 

I just tried another solution by writing an expression to the table widget but unfortunately this does not work as well. 

Here is the expression I tried: 

var portal = Portal('https://www.arcgis.com/');
var fs = FeatureSetByPortalItem(
  portal,
  '4fdb27f2078b4a04bd141a7e9dd05db5',
  0,
  [
    'facility_name_',  //field that includes name of the PCHs
    'DaysFromRefDate',    //field that counts days from the date of survey submission 
    'is_the_site_in_outbreak',  //field that shows if PCH is in outbreak (Categories: 'Yes' and 'No')
    'date_and_time_of_data_submissio' //Date and time of survey submission
  ],
  false
);
 
var output = []   //empty array
 
//Grouped the submissions by Facility name to get latest record 
//'MIN' statistic for the 'is_the_site_in_outbreak' shows outbreak status within the latest record
var fs_gp = (GroupBy(fs, ['facility_name_'], [{name: 'MaxDayFromRefDate', expression: 'DaysFromRefDate', statistic: 'MAX'}, {name: 'Outbreak', expression: 'is_the_site_in_outbreak', STATISTIC: 'MIN'}]))
 
for (var i in fs_gp) {
  if ('Outbreak' == 'Yes') {
    Push(output, i) //Add only those latest records into the empty array which have 'is_the_site_in_outbreak' = 'Yes'
  }

}
return output;
 
Issue: This code returns an array of 0 length. Can someone please assist me? 
0 Kudos