nach Anzahl Sortieren
Hallo zusammen,
ich steh mal wieder komplett auf dem Schlauch...
Folgender Code tut was er soll, ich hätte jetzt nur gerne, das die Liste nach Anzahl der Verwendung der Instrumente sortiert wird. (absteigend)
let my := this;
let myArray := unique(Setlist.'Stück'.Stimmen.Spur.Instrument);
let myArray2 := for ii in myArray do
cnt(Liste.'Stück'.Stimmen.Spur[Instrument = ii].Instrument) + "x " +
record(Instrument,ii).Bezeichnung
end;
join(myArray2, "
")
Kurze Erklärung:
ich befinde mich in einer Setlist.
In der Liste sind die verknüpften Stücke. Ein Stück besteht aus Stimmen, in einer Stimme können mehrere Spuren sein. Eine Spur ist dann mit einem Instrument verknüpft.
Die Anzahl wird mir korrekt vor der Instrumentenbezeichnung angezeigt, aber eben nicht sortiert.
Order by funktioniert in Zeile zwei irgendwie nicht...
Danke schon mal im Voraus!
VG Johannes
10 Antworten
-
Moin ,
versuche es mal mit sort()
https://forum.ninox.de/t/35yh5j5/sort
Vg Ronald -
You can use JSON to create a new "table" that has the count in it then you can sort by the new "count" field.
Here is an example:
You can take this code:
Formula 3 (select Table1).{ recID: Id, countOf: count(TableA) } then you can add the order by Formula 4 (select Table1).{ recID: Id, countOf: count(TableA) } order by -number(countOf)
You can see that Formula 4 adds the order by command. As JSON data is typed as any, we have to use the number() command to convert the data in 'countOf' into a number. Then we use the simple '-' in front of number to tell Ninox to do descending.
-
I think this will work with your code:
let myArray := unique(Setlist.'Stück'.Stimmen.Spur.Instrument); let myJSON := for ii in myArray do { count: cnt(Liste.'Stück'.Stimmen.Spur[Instrument = ii].Instrument) txt: cnt(Liste.'Stück'.Stimmen.Spur[Instrument = ii].Instrument) + "x " + record(Instrument,ii).Bezeichnung } end; concat((myJSON order by -number(count)).txt) -

better visualization of the information, witn the same script.
Content aside
- Status Answered
- vor 7 TagenZuletzt aktiv
- 10Antworten
- 79Ansichten
-
4
Folge bereits
