Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Expert,
I have a question that want to seek an answer.
I have a field D in which I saved different logics based on field A, field B or field C.
Then I need to calculate D in the scripts, because my real data have many many different logics.
So the output from the scripts should be:
May I know if you have any ideas on how to realize it, thanks!
What is the logic behind for D column from row level?
Try this,
tab1:
LOAD RowNo() As ID,* INLINE [
A, B, C, Exp_D
1, 2, 0.95, A*B*C
1000, 20, 1, A*C
1, 100, 2, B*C
];
Expression 😧 Pick(ID,A*B*C,A*C,B*C)
Ouput:
Hi Saran,
This method is ok for this file, but for my real data, there are around 100K row with around hundred logics in different rows.
So i think i can't write pick function for it.
The D column is defined by user to calculate the rate value based on different conditions.
So I have hundred logics in different rows of data like below. I have the field sales_selling_price, total_gold_value and org_labour_cost. So i need to based on the expression to calculate the logic out.
I have solved my question already by using the loop function. thanks
Try this. If you think its faster than your code, you can use it.
tab1:
LOAD RowNo() As ID,* INLINE [
A, B, C, Exp_D
1, 2, 0.95, A*B*C
1000, 20, 1, A*C
1, 100, 2, B*C
];
tab2:
LOAD Concat(Exp_D,',',ID) As StrPick
Resident tab1;
Let vPick=Peek('StrPick');
tab3:
LOAD ID, A, B, C, Pick(ID,$(vPick)) As D
Resident tab1;
Drop Table tab1, tab2;