View of table sorted by date within groups
I have a table that I want to create a view group my people, sorted by date of records by people and then sliced within each sorted group.
I have it working for a specific person but want to process the entire table and show the full results in a view.
here is what is working for a single person.
let h := PlayersHandle.Handle;
let d := ((select Rounds where Players.Handle = h) order by today() - 'Date Played');
let c := cnt(d);
let e := (slice(d, min(0, c - 20), 20) order by Differential);
slice(e, min(0, 1), 8)
13 replies
-
I have an idea on this. I have a people table with an entry for each person. If I can read each record and process the code I have above looping through for each record until done. I would change h to be let h:= People.Handle.
How can i wrap the above code with process reading through the people table until done?
-
I'm not sure what you are trying to do with the min() command in the slice.
Line 4, you ask Ninox to find the minium between 0 and a formula. If the formula is below 0 then it will select the lower number. Then you ask Ninox to use that number in a slice. But an array can never have a starting number below 0, so I'm guessing that it just uses the first instance which is 0.
Line 5, you ask to find the minimum of 0 or 1 so it will always be 0, so why not just use 0?
Just to clarify, you want to find the first 8 Rounds records based on each Handle?
-
said:
I would change h to be let h:= People.Handle.Does that mean you have a reference field on the same table to People?
If so then can you do:
let d := People.Handle.Players.Rounds
If you do it this way you don't have to do a select.
You can also stack order bys. Try:
let d := (((People.Handle.Players.Rounds) order by today()-'Date Played') order by Differential)
You might want to play with the order of the order by to make sure it sorts the data correctly.
If I have some baseball scores and I wanted to sort all records in the BOXSCORES table by city then by date it turns out I have to put the date sort first then the city sort.
(((select BOXSCORES) order by Date) order by PARK.CITY)
-
Try the following for your view element code:
let allPeople := (select People); let newArray := (select Rounds)[= -1]; for person in allPeople do let y := ((Handle.Players.Rounds order by today()-'Date Played') order by Differential); let b := slice(y, 0, 8); newArray := array(newArray, b); end; newArray
It took me awhile to figure how to initialize the empty array on line 2. Not only does it have to be initialized to accept nid, but it has to match the exact table you are trying to add to.
Content aside
- Status Answered
- 1 mth agoLast active
- 13Replies
- 99Views
-
2
Following