<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Issue with creating featureset using the arcade script below? in ArcGIS Online Developers Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-developers-questions/issue-with-creating-featureset-using-the-arcade/m-p/1495557#M1410</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have tried to fix the error that keeps occurring with the code that I am using below. I have tried researching and trying to find a solution but all of my attempts have yielded the same result. I would greatly appreciate any help with this arcade expression.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function CalendarSE(){
    var StartMDay = Date(Year(Today()),Month(Today()),1)
    var LastMDay = DateAdd(StartMDay,1,'Month')
    LastMDay = DateAdd(LastMDay,-1,'day')

    var CS = Date(DateAdd(StartMDay,-WeekDay(StartMDay),'day'))
    var CE = Date(DateAdd(LastMDay,6-WeekDay(LastMDay),'day'))
    return {'Start' : CS , 'End':CE }
}

var CS = CalendarSE()['Start']
var CE = CalendarSE()['End']

var DateField = '&amp;lt;dateField&amp;gt;'
var P = Portal('&amp;lt;portal&amp;gt;')
var Item = Filter(FeatureSetByPortalItem(P,'&amp;lt;itemID&amp;gt;',0,[DateField],False),DateField + ' Between &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/158815"&gt;@cs&lt;/a&gt; AND &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/305514"&gt;@CE&lt;/a&gt;')

var DF = 'Y-MM-DD'
var Weekdays = {
    '0':'Sunday',
    '1':'Monday',
    '2':'Tuesday',
    '3':'Wednesday',
    '4':'Thursday',
    '5':'Friday',
    '6':'Saturday'
}

var CalendarFields = []
for( var i = 0 ; i &amp;lt; 7 ; i++ ){
    Push(CalendarFields,{'name': Weekdays[Text(i)] , 'type':'esriFieldTypeDate'})
	Push(CalendarFields,{'name': Weekdays[Text(i)]+'Count' , 'type':'esriFieldTypeInteger'})
}
Console(CalendarFields)
var CalendarTable = {
  'fields': CalendarFields,
  'geometry' : Null,
  'features' : []
}

var DCLimit = {}
for(var i = 0; i &amp;lt; 43; i++){
    var T = DateAdd(CS,i,'days')
    var CD = DateAdd(T,i+1,'days')
    var Cnt = Count(Filter(Item, DateField + ' Between @T AND &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/352010"&gt;@CD&lt;/a&gt;'))
    var W = Weekdays[Text(i%7)]
    DCLimit[W] = Date(T)
    DCLimit[W+'Count']=Cnt
    if( i % 7 == 6 ){
        Push( CalendarTable.features , {'attributes': DCLimit } )
        DCLimit = {}
    }
}

CalendarTable = Featureset( Text(CalendarTable) )
return CalendarTable&lt;/LI-CODE&gt;&lt;P&gt;Any help on this would be greatly appreciated. I would also like to know if there is a simpler way for write this than what I have now.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jun 2024 18:21:59 GMT</pubDate>
    <dc:creator>RPGIS</dc:creator>
    <dc:date>2024-06-20T18:21:59Z</dc:date>
    <item>
      <title>Issue with creating featureset using the arcade script below?</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/issue-with-creating-featureset-using-the-arcade/m-p/1495557#M1410</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have tried to fix the error that keeps occurring with the code that I am using below. I have tried researching and trying to find a solution but all of my attempts have yielded the same result. I would greatly appreciate any help with this arcade expression.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function CalendarSE(){
    var StartMDay = Date(Year(Today()),Month(Today()),1)
    var LastMDay = DateAdd(StartMDay,1,'Month')
    LastMDay = DateAdd(LastMDay,-1,'day')

    var CS = Date(DateAdd(StartMDay,-WeekDay(StartMDay),'day'))
    var CE = Date(DateAdd(LastMDay,6-WeekDay(LastMDay),'day'))
    return {'Start' : CS , 'End':CE }
}

var CS = CalendarSE()['Start']
var CE = CalendarSE()['End']

var DateField = '&amp;lt;dateField&amp;gt;'
var P = Portal('&amp;lt;portal&amp;gt;')
var Item = Filter(FeatureSetByPortalItem(P,'&amp;lt;itemID&amp;gt;',0,[DateField],False),DateField + ' Between &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/158815"&gt;@cs&lt;/a&gt; AND &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/305514"&gt;@CE&lt;/a&gt;')

var DF = 'Y-MM-DD'
var Weekdays = {
    '0':'Sunday',
    '1':'Monday',
    '2':'Tuesday',
    '3':'Wednesday',
    '4':'Thursday',
    '5':'Friday',
    '6':'Saturday'
}

var CalendarFields = []
for( var i = 0 ; i &amp;lt; 7 ; i++ ){
    Push(CalendarFields,{'name': Weekdays[Text(i)] , 'type':'esriFieldTypeDate'})
	Push(CalendarFields,{'name': Weekdays[Text(i)]+'Count' , 'type':'esriFieldTypeInteger'})
}
Console(CalendarFields)
var CalendarTable = {
  'fields': CalendarFields,
  'geometry' : Null,
  'features' : []
}

var DCLimit = {}
for(var i = 0; i &amp;lt; 43; i++){
    var T = DateAdd(CS,i,'days')
    var CD = DateAdd(T,i+1,'days')
    var Cnt = Count(Filter(Item, DateField + ' Between @T AND &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/352010"&gt;@CD&lt;/a&gt;'))
    var W = Weekdays[Text(i%7)]
    DCLimit[W] = Date(T)
    DCLimit[W+'Count']=Cnt
    if( i % 7 == 6 ){
        Push( CalendarTable.features , {'attributes': DCLimit } )
        DCLimit = {}
    }
}

CalendarTable = Featureset( Text(CalendarTable) )
return CalendarTable&lt;/LI-CODE&gt;&lt;P&gt;Any help on this would be greatly appreciated. I would also like to know if there is a simpler way for write this than what I have now.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 18:21:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/issue-with-creating-featureset-using-the-arcade/m-p/1495557#M1410</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2024-06-20T18:21:59Z</dc:date>
    </item>
  </channel>
</rss>

