Dashboard- Arcade Last edit date

870
4
08-03-2021 12:40 PM
RickeyFight
MVP Regular Contributor

I am trying to figure out how to get the last edited feature to be the one filtered out. 

This works for part of the day. There are just a few hours where it does not work. From 10am (local time) until I enter that days data.  I usually enter new data midday.  It does not pull in the last edited based on time. It pulls in based on date and when there are two from the same day it will pull the wrong feature. 

I get No Value because it is pulling the wrong edit date. 

RickeyFight_0-1628019410149.jpeg

 

My expression:

 

var portal = Portal("https:///portal/");
var fs = FeatureSetByPortalItem(
  portal,
  "",
  1,
  [
    "Date_",
    "W_F_MGD",
    "E_F_MGD",
    "TOTAL_W_E_MGD",
    "TID_FLOW_MGD",
    "REEDER_Percent_FULL",
    "TAP_FLOW_MGD",
    "PLANT_PRODUCTION_MGD",
    "last_edited_date"
  ],
  false
);


// Find the most recent date from the date field to filter the FeatureSet for the latest record
var maxDate = Text(Date(ToLocal(Max(fs, 'last_edited_date'))),"YYYY-MM-DD");
return Filter(fs, "Date_ = @maxDate");

 

 

0 Kudos
4 Replies
DavidPike
MVP Frequent Contributor

Can you just find the greatest difference in milliseconds between your UTC last-edited date and another arbitrary date?

var date1 = Date(2020, 1, 1, 1, 1, 1)
var date2 = Now()

return DateDiff(date2, date1)

Also you have 'Inputted' and 'Inputed', I'm not sure ieitheris the correct word as isn't that past tense? Possibly 'input' or 'entered'? Just my 5 cents. 

RickeyFight
MVP Regular Contributor

@DavidPike 

I have fixed the typo thanks. My hope is that if I get this figured out I will not have to worry about which is correct because some data should always be displayed. 
I do like the idea of getting the greatest difference. I just need to figure out how to apply it now. 

0 Kudos
RickeyFight
MVP Regular Contributor

@DavidPike 

I found a blog that has helped. I can sort by last edit date. I can also tell it to display only 1 record. 

https://www.esri.com/arcgis-blog/products/ops-dashboard/real-time/making-an-auto-focusing-real-time-...

 

0 Kudos
DavidPike
MVP Frequent Contributor

That seems much simpler.

0 Kudos