Arcade Wizards: Extract values from one field, where all the data is located.

449
3
Jump to solution
07-25-2023 06:46 AM
ArmstKP
Occasional Contributor III

I have a field named ("last_values") that updates every five minutes, where a whole bunch of data comes in this one field.  See the example data from this field, below.  I want to extract into another field, the value (21.4191) that comes after "field1". Anybody have any ideas

 

{"field4":{"value":5,"created_at":"2023-07-24T19:45:15Z"},"log":{"value":507,"created_at":"2023-07-24T17:03:02Z"},"field3":{"value":181.44,"created_at":"2023-07-24T19:49:59Z"},"field1":{"value":21.4191,"created_at":"2023-07-24T19:55:02Z"},"field2":{"value":55.996,"created_at":"2023-07-24T19:55:02Z"},"field5":{"value":-45,"created_at":"2023-07-24T19:50:06Z"},"wifi":{"value":"ee:55:a8:0a:40:ef,-38;fe:55:a8:0a:40:ef,-38;ee:55:a8:0a:40:bf,-57;fe:55:a8:0a:40:bf,-58;02:18:4a:8c:49:62,-61","created_at":"2023-07-24T17:07:49Z"}}

0 Kudos
1 Solution

Accepted Solutions
RhettZufelt
MVP Frequent Contributor

This works for me in form calculation and popup.

 

var dic = $feature.last_values
var dicvar = Dictionary(dic)
return dicvar.field1.value

 

as per your modified question, this returns the field1.value and returns as a number (21.4191)

Field Maps calculated value:

RhettZufelt_1-1690323857449.png

Popup:

RhettZufelt_0-1690323715824.png

R_

View solution in original post

3 Replies
RhettZufelt
MVP Frequent Contributor

Not sure what you mean by values from field1 and field2.  they are numeric, so you want to add them together or return both values as a text string?

Code below returns as a string on two lines:

var dic = '{"field4":{"value":5,"created_at":"2023-07-24T19:45:15Z"},"log":{"value":507,"created_at":"2023-07-24T17:03:02Z"},"field3":{"value":181.44,"created_at":"2023-07-24T19:49:59Z"},"field1":{"value":21.4191,"created_at":"2023-07-24T19:55:02Z"},"field2":{"value":55.996,"created_at":"2023-07-24T19:55:02Z"},"field5":{"value":-45,"created_at":"2023-07-24T19:50:06Z"},"wifi":{"value":"ee:55:a8:0a:40:ef,-38;fe:55:a8:0a:40:ef,-38;ee:55:a8:0a:40:bf,-57;fe:55:a8:0a:40:bf,-58;02:18:4a:8c:49:62,-61","created_at":"2023-07-24T17:07:49Z"}}'
var dicdata = Dictionary(dic)
var f1 = "Field 1 = " + (Text(dicdata.field1.value))
var f2 = "Field 2 = " + Text(dicdata.field2.value)
return Concatenate(f1 + TextFormatting.NewLine + f2)

RhettZufelt_0-1690308047233.png

Should give you an idea of how to get the values from the dictionary string.

R_

ArmstKP
Occasional Contributor III

@RhettZufelt Thank you for the example.  I have clarified my original post, to better describe what I am trying to do.

I am working on understanding your example -  I have tried the below and got the following error:

ArmstKP_1-1690316070880.png

 

 

0 Kudos
RhettZufelt
MVP Frequent Contributor

This works for me in form calculation and popup.

 

var dic = $feature.last_values
var dicvar = Dictionary(dic)
return dicvar.field1.value

 

as per your modified question, this returns the field1.value and returns as a number (21.4191)

Field Maps calculated value:

RhettZufelt_1-1690323857449.png

Popup:

RhettZufelt_0-1690323715824.png

R_