This code works erratically sometimes it works and other times it doesn't
This code works erratically sometimes it works and other times it doesn't.
delete (select 'Evaluation table');
let myY := year('Evaluation Date');
let myYM := yearmonth('Evaluation Date');
let datorder := ((select Dates where 'Cod Nr' != 1 and yearmonth('Final Date') >= myYM) order by 'Final Date');
for fY in range(myY, year(today()) + 1) do
let myArray := for fM in range(1, 13) do
cnt(datorder[year('Final Date') = fY and month('Final Date') = fM])
end;
let newRec := (create 'Evaluation table');
newRec.(
Year := fY;
Jan := item(myArray, 0);
Feb := item(myArray, 1);
Mar := item(myArray, 2);
Apr := item(myArray, 3);
May := item(myArray, 4);
Jun := item(myArray, 5);
Jul := item(myArray, 6);
Aug := item(myArray, 7);
Sep := item(myArray, 8);
Oct := item(myArray, 9);
Nov := item(myArray, 10);
Dec := item(myArray, 11)
)
end
Some idea
9 replies
-
The idea is this, but continues erratical
-
Can you be more descriptive by what you mean "erratically"?
Looking at the code it looks like it is doing what you are asking with the data provided.
-
said:
A small video to see the problem.I don't see a problem. The first time you click the button your are on a record with Cod hr = 600 with a final date of 12 Dec 2024. Then you open and close the DB and then click on a record with Cod hr = 17 that has a final date of 29 Nov 2023.
You have this on line 4 of your button:
let datorder := ((select Dates where 'Cod Nr' != 1 and yearmonth('Final Date') >= myYM) order by 'Final Date')
The first time you click the button with:
Final Date = 12 Dec 2024
Evaluation Date = 2 Dec 2024
the datorder will find records in Dates with a yearmonth() that is equal to or greater than 2024/12. From the looks of it you only have 3 records that match.
The second time you click on the button with:
Final Date = 29 Nov 2023
Evaluation Date = 20 Nov 2023
the datorder will find records in Dates with a yearmonth() that is equal to or greater than 2023/11. It looks like you have records from 2023 and 2024 that match this and thus you get more data.
Content aside
- Status Answered
- 8 mths agoLast active
- 9Replies
- 55Views
-
2
Following