Extract Record from a Table meeting some criteria
Hi to all,
i have a table called Album, with a relationship with another Table Called Release (1:N)
Each album could have 0, 1, or multiple Releases
i am trying to extract in a formula field the name of the album which has the wMax amount or releases connected on it.
I am trying with this formula:
let maxCount := 0;
let albumName := "";
for i in Album do
let releaseCount := count(i.Releases);
if releaseCount > maxCount then
maxCount := releaseCount;
albumName := i.Album
end
end;
albumName
but I get no response. Any suggestions?
Thank you in advance
3 replies
-
When I copy your code into a test DB I get an error at i.Releases and i.Album. To correct that I had to fix line 3:
for i in select Album do
I'm guessing you wanted to go through the entire Album table so you need to use a select statement. Otherwise Ninox assumes you want to loop through the field Album.
-
We like a one liner, this might work
last((select Album) order by count(Release)).Album
Regards John
-
Fixed, thank you a lot
Content aside
- Status Answered
- 1 yr agoLast active
- 3Replies
- 89Views
-
3
Following