Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everybody,
i have this table
IDDEVICE IDFIELD ENERGY
a 1 50
a 1 40
b 1 70
b 1 60
c 1 100
c 1 110
d 2 100
d 2 10
e 2 205
e 2 200
f 3 10
g 4 15
Does exist some kind of FOREACH that i can use like this:
if ( IDFIELD = 1,
FOREACH IDDEVICE take max(ENERGY)
)+
if ( IDFIELD = 2,
FOREACH IDDEVICE take max(ENERGY)
)+
.....
What do you do with the list of max(Energy) values then? Sum them up?
Could you give an example of your expected outcome?
Maybe you could use something like
=sum( {<IDFIELD={1}>} aggr(max( {<IDFIELD={1}>} ENERGY), IDDEVICE))
Hi,
Did you expect this in script expression?
If so then you can do this by using group by like
Load
IDFIELD,
Max(ENERGY)
Resident
TableName
GROUP BY IDFIELD;
Hope it helps
Celambarasan
What do you do with the list of max(Energy) values then? Sum them up?
Could you give an example of your expected outcome?
Maybe you could use something like
=sum( {<IDFIELD={1}>} aggr(max( {<IDFIELD={1}>} ENERGY), IDDEVICE))
SWUEHL
Yes i want the SUM and your expression works good.
In the same way, can i group by IDFIELD too ?
Probably yes,
(I am not 100% sure what you are looking for, again, describing your expected outcome might help here):
try
=sum( aggr(max( ENERGY), IDFIELD, IDDEVICE))
SWUEHL
one last question:
Now i want to take the Min value of energy but only where ENERGY > 0
=sum( aggr(MIN( ENERGY), IDFIELD, IDDEVICE))
i'm trying to put IF(ENERGY>0,......) everywhere in the expression but seems not working...
thanks
Try a set expression
=sum({<ENERGY = {">0"}>} aggr(MIN({<ENERGY = {">0"}>} ENERGY), IDFIELD, IDDEVICE))