Select to view content in your preferred language

Calculating Average Number of Missions Per Week, Per Month, and Per Quarter

282
5
3 weeks ago
Labels (1)
Zelong
by
Occasional Contributor

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.

0 Kudos
5 Replies
Neal_t_k
MVP Regular Contributor

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> / currentMonth

For Quarter:

var currentDate = Now()
var currentMonth = Month(currentDate)
var currentQuarter = When(
    currentMonth <= 3, 1,
    currentMonth <= 6, 2,
    currentMonth <= 9, 3,
    4
)
var quarterRate = <sumFlights> / currentQuarter

Get 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.

 

0 Kudos
Zelong
by
Occasional Contributor

I would use the indicator in Dashboard, what would i use in Experience Builder?

0 Kudos
Neal_t_k
MVP Regular Contributor

Not sure, not as familiar with Experience Builder and haven't used it in a while.

0 Kudos
Neal_t_k
MVP Regular Contributor

@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)

 

Neal_t_k_0-1766417927230.png

Arcade3:

var fs =$dataSources["<datasourcdID>"].layer;
var countFlight = Count(fs);
return countFlight

Arcade4:

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 weekRate

Arcade5:

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
0 Kudos
Zelong
by
Occasional Contributor

I will try that thanks.

0 Kudos