0

selecting only first record meeting a criteria

Hi to all!

Database tables

Masters

 Reference

 Events

 

 inside a the Events Table I have this formula:

let xEvent := Event;
let xDate := Date;
let x := (select Reference where Date = xDate and Event = xEvent);
for i in x do
let y := (select Masters where 'Master Release Code' = i.'Master Release Code');
for j in y do
html(---  <span style="color: #191970">{ i.Track } </span></br>
<span style="color: #191970">{ j.'Master Release' } </span></br>
<img src="{ y.coverimage }" style="width: 60px; height: 60px; margin-right: 5px;"></br>  ---)
end
end

that shows this output:

as you can see the tracks are duplicated and in order to avoid this I am trying:

 

let xEvent := Event;
let xDate := Date;
let x := (select Reference where Date = xDate and Event = xEvent);
let previousTracks := [];
for i in x do
    let track := i.Track;
    if not contains(previousTracks, track) then
        let y := (select Masters where 'Master Release Code' = i.'Master Release Code');
        for j in y do
            previousTracks := previousTracks + track;
            html(---
                <span style="color: #191970">{ track } </span></br>
                <span style="color: #191970">{ j.'Master Release' } </span></br>
                <img src="{ y.coverimage }" style="width: 60px; height: 60px; margin-right: 5px;"></br>
            ---)
        end
    end
end

 

but it doesn't help....

 

any suggestions? thank you for the attention

4 replies

null
    • szormpas
    • 1 yr ago
    • Reported - view

    Hi , could you tell us the Table relationships ?

      • francescostefanello
      • 1 yr ago
      • Reported - view

       There are no relationships between tables according to Ninox's criteria, but the relationships are defined directly in the script within the formula.

    • John_Halls
    • 1 yr ago
    • Reported - view

    Hi

     

    Would the use of unique help? I've only quickly glanced at your code. It would either go here

    let x := unique(select Reference where Date = xDate and Event = xEvent);
    

    or here

    let y := unique(select Masters where 'Master Release Code' = i.'Master Release Code');
    

    Regards John

    • francescostefanello
    • 1 yr ago
    • Reported - view

    Hi John, thank you

     

    i will work with this

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 4Replies
  • 128Views
  • 3 Following