Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
LOAD * INLINE [
F1, F2, F3
A, 23, 18
B, 24, 12
C, 25, 34
];
lET VT1=SUM(F2);
lET vT2=SUM(F3);
Let vt= if([F1]="A",VT1,vT2);
What is the wrong with the if statement;
please find attached a revised version
Data:
LOAD * INLINE [
F1, F2, F3
A, 23, 18
B, 24, 12
C, 25, 34
];
sumtab:
LOAD
sum(F2) as F2sum,
sum(F3) as F3sum
Resident Data;
LET VT1 = Peek('F2sum');
LET VT2 = Peek('F3sum');
Result:
LOAD
sum(if([F1]='A', $(VT1),$(VT2))) as Result
Resident Data;
LET vt = Peek('Result');
for the first part consider the script below. The if statement cant work as a variable can only store one value at a time.
Data:
LOAD * INLINE [
F1, F2, F3
A, 23, 18
B, 24, 12
C, 25, 34
];
sumtab:
LOAD
sum(F2) as F2sum,
sum(F3) as F3sum
Resident Data;
LET VT1 = Peek('F2sum');
LET VT2 = Peek('F3sum');
Field names are cannot use directly in the variables either it could use Peek or FieldValue
I hope your intention is different. Let me know whether below script helps you
T:
LOAD * INLINE [
F1, F2, F3
A, 23, 18
B, 24, 12
C, 25, 34
];
T1:
Load F1, If(F1='A', Sum(F2), Sum(F3)) AS VT
Resident T
Group By F1;
Hi Daniel,
I want to pick only one value. And I have to display it in a Text Object.
please find attached a revised version
Data:
LOAD * INLINE [
F1, F2, F3
A, 23, 18
B, 24, 12
C, 25, 34
];
sumtab:
LOAD
sum(F2) as F2sum,
sum(F3) as F3sum
Resident Data;
LET VT1 = Peek('F2sum');
LET VT2 = Peek('F3sum');
Result:
LOAD
sum(if([F1]='A', $(VT1),$(VT2))) as Result
Resident Data;
LET vt = Peek('Result');
You don't need variables in script. Try this expr in Text box
=If(Max(Aggr(Max(If(F1='A',1,0)),F1)) = 1,Sum(F2),Sum(F3))
Hi Hari,
I am going to help you. What is exact requirement...?
Hi Hari,
i think Daniel reply is help you...
Ramya
Hi Ramya,
Daniel has resolved the issue.
Req; Summing coulmn of values based on another coulmn value.
Thank you.