On the attached picture the is a straight table with several results.
A result can be positive (in green) or negative (in red).
What I need to do is count how many negative results are in the first 3 values of the table (the ones with the biggest hour), but I don't understand how.
What exactly are you looking for? Only first three record of the table neither they are positive or negative, and if they are negative to calculate them?
Or only first three negative values that appearing in data set among others, i.e. in your pic there are 10 green values and then two red, so for you result should be 2? Two negative values?
And where do you calculate negative and positive, in script or in UI using expression? Simple way is in script add Negative, Positive flag, f.e.
Table1:
Load
A,
B,
C,
if(C<0,0,1) as PNflag
from abc.dbo.....
In result you will see the table like that:
A
B
C
PNflag
3316
56789
123
1
3317
35488756
223
1
3318
48564767
-222
0
3319
474846
-333
0
3320
-444
0
3321
555
1
So, using similar logic in script helps you further to count negative values in more esier way. This is true in order if you can identify positive or negative in script. In other way it will be more interesting solution using advanced formulas.