Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
group | value |
---|---|
A | 14 |
A | 23 |
A | 53 |
B | 4 |
B | 63 |
B | 13 |
B | 7 |
When loading the data, I want to set variables of each group(A and B)
SET vAverageA = (average value of group A)//(14+23+53)/3
SET vAverageB = (average value of group B)//(4+63+13+7)/4
Does anybody know how to do this?
May be this:
Table:
LOAD * Inline [
group, value
A, 14
A, 23
A, 53
B, 4
B, 63
B, 13
B, 7
];
AggrTable:
LOAD Avg(value) as Avg,
group
Resident Table
Group By group
Order By group;
For i = 1 to FieldValueCount('group')
vField = FieldValue('group', $(i));
TempTable:
NoConcatenate
LOAD Avg
Resident AggrTable
Where group = '$(vField)';
LET vAverage$(vField) = Peek('Avg');
DROP Table TempTable;
NEXT i
Drop Table AggrTable;
May be this:
Table:
LOAD * Inline [
group, value
A, 14
A, 23
A, 53
B, 4
B, 63
B, 13
B, 7
];
AggrTable:
LOAD Avg(value) as Avg,
group
Resident Table
Group By group
Order By group;
For i = 1 to FieldValueCount('group')
vField = FieldValue('group', $(i));
TempTable:
NoConcatenate
LOAD Avg
Resident AggrTable
Where group = '$(vField)';
LET vAverage$(vField) = Peek('Avg');
DROP Table TempTable;
NEXT i
Drop Table AggrTable;
Thank you so much!! It worked!!