Getting the max value of an array with multiple keys

Hello,

I have an array like this:

“value”: [{
“timeseries”: [{
“data”: [
{“timeStamp”:“09:15”,“maximum”:45},
{“timeStamp”:“09:16”,“maximum”:60},
{“timeStamp”:“09:17”,“maximum”:55}
]
}]
}]

How can I get the Maximum of all the values inside the data array (expected 60)?

1 Like

Heyy @hktokka Welcome to the community!

You can use this formula to get the max value from your data array.

{{max(map(9.value[].timeseries[].data; "maximum"))}}

Where you can replace the array part with your timeseries array.

I hope this helps!

Best,
@Prem_Patel

4 Likes

Thanks @Prem_Patel
It works!

2 Likes

Glad it helped! @hktokka

Welcome to the Make community!

To do this, you can use these built-in functions:

  • map
    map(complex array; key; [filter by key]; [csv-values for filtering])

  • max
    max([array of values]), max(value1;value2; ...)

I’d recommend going through the Make Academy if you haven’t yet, as these functions have been covered — refer to the Make Academy Course Overview to learn more.

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

Learn Make

How-Tos

@samliew
P.S.: investing some effort into the tutorials in the Make Academy will save you lots of time and frustration using Make!