I'm trying to create an indicator in my dashboard that includes only the records in my dataset from the month associated with the most recent records. (I don't want to use the built in Last Month option in the Data options section of the indicator because there will be a lag at the beginning of each month when the dashboard is updated.)
I'm trying to write an Arcade expression for this but am a newcomer and am struggling a bit with this.
Right now my expressions runs but it only returns the records associated with the latest date, not all of the records in the latest month which is what I want. See expression below - if I change YYYY-MM-DD in the 4th line to MMM, then no records are returned.
I feel like there's probably a very simple solution to this but I can't seem to figure it out.
Any suggestions are appreciated.
Thank you,
Samara
var fields = ["objectid", "date", "category", "closed"]
var fs = FeatureSetByPortalItem(Portal("PORTAL NAME"), "LAYER ID", 0, fields)
var open_issues = Filter(fs, "closed = 'No'")
var maxDate = Text(Date(Max(open_issues, 'date')), 'YYYY-MM-DD')
var subsetByDate = Filter(open_issues, "date = @maxDate")
return subsetByDate
Solved! Go to Solution.
Do you want to return records from the last month as of today's date? You can use the DateAdd function to calculate that date, then use that date to filter the records.
var fields = ["objectid", "date", "category", "closed"]
var fs = FeatureSetByPortalItem(Portal("PORTAL NAME"), "LAYER ID", 0, fields)
var open_issues = Filter(fs, "closed = 'No'")
var lastMonth = Text(DateAdd(Today(), -1, 'months'), 'MM/DD/YYYY');
var subsetByDate = Filter(open_issues, "date > @lastMonth")
return subsetByDate
Do you want to return records from the last month as of today's date? You can use the DateAdd function to calculate that date, then use that date to filter the records.
var fields = ["objectid", "date", "category", "closed"]
var fs = FeatureSetByPortalItem(Portal("PORTAL NAME"), "LAYER ID", 0, fields)
var open_issues = Filter(fs, "closed = 'No'")
var lastMonth = Text(DateAdd(Today(), -1, 'months'), 'MM/DD/YYYY');
var subsetByDate = Filter(open_issues, "date > @lastMonth")
return subsetByDate
Yes, this allows me to do what I'm aiming for - thank you so much!
Samara