on 11-26-2008 7:03 AM
Hi , I am looking for help in mapping for the following scenario.
I have a segment (multiple occurances) in the source as shown below:
dicounts
itemno
disocountType
amount
Target segment (one occurance) looks like this:
discountTotals
disocountType
amount
The total of all amounts of a particuler discount type needs to be moved to target amount field.
Example:
dicounts
itemno:1001
disocountType:K
amount:100
discounts
itemno:1002
disocountType:K
amount:200
discounts
itemno:1001
disocountType:P
amount:150
the total of all discounts of type: K has to be moved to target segment
Target segment:
discountTotals
disocountType: K
amount:300
We tried to use functions : SUM and removeContexts, but not able to impose conditions. Its adding all the disocounts(irrespective of discount type=K) and returning 450 (100200150).
Thanks,
Rajesh
Hi,
Do like this, actually in your case sum is taking place before the condition check for discount type
do a little change in mapping
DiscntType--removeContext--
EqulsS-------IfWithoutElse----Amount---removecontext--then---SUM-
Connstatnt(Value)
--->GrandAmount
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
disocountType \
------------equalS----\
Constant[K] / ----------ifWitoutElse---- removeContext-------sum(from statistics group)----target
amount--/
ifWitoutElse 2 inputs :-
1. check whether discount type equals K
2.amount
Don't change content of any of the input. removeContext will carry all amounts whose discountType is K, sum will add up all amounts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all, thanks a lot for the response. I followed the logic provided by sudhir and able to get the required output.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please use the mapping below:
for the discountTotals node:
discountType --> removeContext --> sort: Lexicographical(case insensitive) --> splitByValue:ValueChanged --> collapseContext --> discountTotals
this creates the discountTotals node based on the number of the discountType unique occurrences
for the discountType node:
discountType --> removeContext --> sort: Lexicographical(case insensitive) --> splitByValue:ValueChanged --> collapseContext --> splitByValue:eachValue --> discountType
same as above, e.g. if only P and K are declared, then the mapping will only output a P and a K once
for the amount node:
discountType --> removeContext --> sortByKey:(LexicographicalCaseInsensitive) 1.
amount --> removeContext -->
discountType ->removeContext ->sort:Lexicographical(CaseInsensitive) ->splitByValue:ValChngd 2.
node from 1. --> formatByExample --> sum --> amount
node from 2. -->
before you can do a total for each type (P or K), you have to use formatByExample to separate which values belong to P or K. The mapping also took into account that the occurrence order could be P,K,P,K...so that using formatByExample with sort will result to P,P,K,K.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use the remove context for both DicountType and Amount while checking the condition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use the mapping like below..
disocountType(same context)-equalsS(TextFunction)IfWithouElseamount(Parent Context)(Then)-->
disocountType(Parent Context)
->RemoveContextSum(Statistic Function)-Target(amount).
Regards,
Prakasu
Edited by: prakasu on Nov 26, 2008 8:23 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
you can try like that.
amount -
> remove context---->sort by key(disocountType(remove contect))
here sort the maount value by keeping discount type as key...
regards,
navneet
Edited by: navneet sumit on Nov 26, 2008 8:30 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.