Maxumum dans un tableau.

37 views
Skip to first unread message

RG T

unread,
Dec 14, 2025, 1:00:31 PMDec 14
to mementodatabase
Bonjour à tous,
Dans une base de donnée  rassemblant les données journalières d'une station météo, je voudrai connaître l'indice UV maximum de la journée et non oas sur la base entière. J'ai crée ce code mais il me renvoi NaN alors que les données ne sont que des chiffres (0 à 15). J'ai crée un tableau et j'utilise Math.max pour rechercher dans ce tableau la valeur maximum. 
Merci pour votre aide.

Hello everyone,
In a database containing daily data from a weather station, I want to know the maximum UV index for the day, not the maximum UV index for the entire database. I created this code, but it returns NaN even though the data consists only of numbers (0 to 15). I created an array and I'm using Math.max to search for the maximum value within it.
Thank you for your help.

//---CALCUL INDICE UV
//---DECLARATIONS VARIABLES ---
var e = entry();
var UV8 = entry().field("Indice UV 8");
var UV9 = entry().field("Indice UV 9");
var UV10 = entry().field("Indice UV 10");
var UV11 = entry().field("Indice UV 11");
var UV12 = entry().field("Indice UV 12");
var UV13 = entry().field("Indice UV 13");
var UV14 = entry().field("Indice UV 14");
var UV15 = entry().field("Indice UV 15");
var UV16 = entry().field("Indice UV 16");
var UV17 = entry().field("Indice UV 17");
var UV18 = entry().field("Indice UV 18");
var UV19 = entry().field("Indice UV 19");
var UV20 = entry().field("Indice UV 20");

//-CREATION TABLEAU
var UV = [UV8 , UV9, UV10 , UV11 , UV12 (UV13 , UV14 , UV15 , UV16 , UV17 , UV18 , UV19 , UV20];

//-RECHERCHE MAX
var UV1 = Math.max(UV);

//-RESULTATS
"▪︎ ☀️ ▪︎ "+UV1+"\t\t\t\t\t\t\t\t("+ UV //<< CONTRÔLE

Bill Crews

unread,
Dec 14, 2025, 1:47:51 PMDec 14
to RG T, mementodatabase
The first thing that comes to mind is to avoid scripting altogether, but rather just group by day (right-side menu in Android) and see whatever you want in the summary bars using Aggregation. 

La première chose qui me vient à l'esprit est d'éviter complètement l'utilisation de scripts, et de simplement regrouper les données par jour (via le menu de droite sous Android) et de consulter les informations souhaitées dans les barres récapitulatives à l'aide de la fonction d'agrégation.


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mementodatabase/CAKZ-ewv%3DG18HcNLTU35pn5FsF1DLs8hciPBDWpfTHjdneMKqbA%40mail.gmail.com.

Mmm

unread,
Dec 14, 2025, 2:24:36 PMDec 14
to mementodatabase
Было (... UV12 (UV13 ...):
var UV = [UV8 , UV9, UV10 , UV11 , UV12 (UV13 , UV14 , UV15 , UV16 , UV17 , UV18 , UV19 , UV20];

Должно быть:
var UV = [UV8 , UV9, UV10 , UV11 , UV12, UV13 , UV14 , UV15 , UV16 , UV17 , UV18 , UV19 , UV20];

воскресенье, 14 декабря 2025 г. в 21:47:51 UTC+3, bill....@gmail.com:

RG T

unread,
Dec 14, 2025, 2:29:58 PMDec 14
to Mmm, mementodatabase
Merci Mmm, j'ai corrigé, mais cela ne change rien au problème, j'ai toujours Nan.

Спасибо, я исправила, но это не решает проблему, у меня всё ещё есть бабушка.

Er Mo

unread,
Dec 14, 2025, 2:47:39 PMDec 14
to mementodatabase
Hallo
Wenn du alle Daten aufrufst kannst du diese auch kleich kontrolieren . Du setzt den ersten wert in die Variable " UV " . Dann nimmst du den Nächste Wert , wenn diese größer als UV ist schreibst du diesen In UV . So hast du am ennte den Größten wert in UV stehen .

Bonjour

Si vous avez accès à toutes les données, vous pouvez les vérifier immédiatement. Vous stockez la première valeur dans la variable « UV ». Ensuite, vous prenez la valeur suivante ; si elle est supérieure à UV, vous l'inscrivez dans UV. De cette façon, vous obtiendrez finalement la valeur maximale dans UV.

Ernst

Mmm

unread,
Dec 14, 2025, 3:14:43 PMDec 14
to mementodatabase
 Поле JS:

let hh = 8;
let max = 0;
while (hh < 21) {
    max = field("UV" + hh) > max ? field("UV" + hh) : max;
    hh++;
}

max;

воскресенье, 14 декабря 2025 г. в 22:47:39 UTC+3, ernst...@gmail.com:

RG T

unread,
Dec 14, 2025, 3:22:38 PMDec 14
to Mmm, mementodatabase
Merci Mmm je vais essayer
Спасибо. Ммм, я попробую.

Mmm

unread,
Dec 14, 2025, 3:39:04 PMDec 14
to mementodatabase
С массивом:

let hh = 8;
let uv = [];
while (hh < 21) {
  uv.push(Number(field("UV" + hh)));
  hh++;
}

Math.max.apply(null, uv);

воскресенье, 14 декабря 2025 г. в 23:22:38 UTC+3, trg...@gmail.com:

Mmm

unread,
Dec 14, 2025, 3:44:54 PMDec 14
to mementodatabase
И без массива:

let hh = 8;
let max = 0;

while (hh < 21) {
  max = Math.max(Number(field("UV" + hh)), max);
  hh++;
}

max;

воскресенье, 14 декабря 2025 г. в 23:39:04 UTC+3, Mmm:
Reply all
Reply to author
Forward
0 new messages