Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Shir63
Contributor III
Contributor III

Giving value to duplications based on ruling

Hi Guys,

hope you can help me with this one:

I have duplications in my data (and I need it). I want to build an "Adjusted Price" column:

1. if line id is duplicated then  Adjusted Price would be 0, except the "B" one, that should get the original price.

2. if line id is not duplicated then I want the price to be as the original Price.

3. for lines where B does not exist and there is duplication, then randomly give original price to one  and the other ones would get 0.

ultimately it should like this: 

Order IdModifierOriginal PriceAdjusted Price
111A1000
111B100100
111C1000
111D1000
112B200200
112C2000
113D170170
113C1700
113A1700
114
A125125
115
C110110
115
D1100

 

I have built a column to recognize the duplicated id using:

left join Table:

load Distinct " Order Id",
If(Count( "Order Id")>1,1) as Duplicate

resident Discount
Group By "Order Id";

and also I have built a formula for this to work, but it doesn't work for all cases:

IF(Original Price- PEEK(Original Price)=0 and duplicate = '1' and Peek("Order Id") = "Order Id" and MODIFIER <> 'B',0,
if (duplicate = '1' and MODIFIER <> 'B', Original Price)) AS "Price Adjusted"

please help me with your wisdom 🙂

Labels (1)
11 Replies
Shir63
Contributor III
Contributor III
Author

Thank you!

that worked.

for larger data samples i would not suggest to use " Autonumber" as it slows the model, or makes it impossible,

i have used a different approach for the autonumber: 

IF("Sale Order Line Id" = Previous("Sale Order Line Id"), RangeSum(Peek(ID),1),1) as Key

thank you all for the help!!

you guys are the best

Saravanan_Desingh

you welcome