In an experience builder that I am making for the Drone Unit that I run, I am trying to figure out the following.
Using my Survey 123 form that I use to track my missions I want to show the average number of missions per:
Week
Month
Quarter
I think I would be average using the mission count (object Id) but I am not sure how to calculate the averages.
I think you will have to do some Arcade work for this, you are posting this in the Dashboard Question section but you description references Experience Builder. So without clarification I will just supply you with my thought on how to handle it in a dashboard, It should be similar in ExB.
For Weekly rate. The first step would be to determine the number of days since Jan 1. In Arcade you will make to variable one for now() and one for Jan. 1. and then use DateDiff to get the Julian date then divide by 7 to get the number of weeks.
var currentDate = now()
var startOfYear = Date(Year(currentDate), 1, 1)
var dayOfYear = DateDiff(currentDate, startOfYear, 'days') + 1
var weekRate = <sumflights>/ (dayOfYear/7)For monthly rate:
var currentDate = Now()
var currentMonth = Month(currentDate)
var monthRate = <sumFlights> / currentMonthFor Quarter:
var currentDate = Now()
var currentMonth = Month(currentDate)
var currentQuarter = When(
currentMonth <= 3, 1,
currentMonth <= 6, 2,
currentMonth <= 9, 3,
4
)
var quarterRate = <sumFlights> / currentQuarterGet the sum of you drone flights may vary on where the Arcade is located, but for instance if using a Dashboard indicator and your indicator is set to count ObjectID, in your arcade your variable for total flights would be something like this:
var sumFlight = $datapoint["count"]Hopefully that will get you started.
I would use the indicator in Dashboard, what would i use in Experience Builder?
Not sure, not as familiar with Experience Builder and haven't used it in a while.
@Zelong Again not as familiar with Ex Builder, but it appears that if you want to replicate an indicator in ExB, you add a Text widget, and then can build your arcade in there. Assuming in your feature layer, 1 row per flight, to get your count of drone flights would be something like this:
var fs =$dataSources["<datasourcdID>"].layer;
var countFlight = Count(fs)
Arcade3:
var fs =$dataSources["<datasourcdID>"].layer;
var countFlight = Count(fs);
return countFlightArcade4:
var fs =$dataSources["<datasourcdID>"].layer;
var countFlight = Count(fs)
var currentDate = now()
var startOfYear = Date(Year(currentDate), 1, 1)
var dayOfYear = DateDiff(currentDate, startOfYear, 'days') + 1
var weekRate = countFlight/ (dayOfYear/7)
return weekRateArcade5:
var fs =$dataSources["<datasourcdID>"].layer;
var countFlight = Count(fs)
var currentDate = Now()
var currentMonth = Month(currentDate)
var monthRate = countFlight / currentMonth
return monthRate Arcade 6:
var fs =$dataSources["<datasourcdID>"].layer;
var countFlight = Count(fs)
var currentDate = Now()
var currentMonth = Month(currentDate)
var currentQuarter = When(
currentMonth <= 3, 1,
currentMonth <= 6, 2,
currentMonth <= 9, 3,
4
)
var quarterRate = countFlight / currentQuarter
return quarterRate
I will try that thanks.