Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I've trying to do this in the script, managed to do it with an expression.
I want to find the lowest priced product per SubId and apply a discount (in this case 50%) and then sum the Totals.
FirstsortedValue should work i guess but I'm doing something wrong 🙂
This is the expression:
(Sum(FullPrice)
-
(Min({<flgNewOrder = {'1'}>} Aggr(FullPrice, [Product ID]))
*0.5))
SubId | ProdId | FullPrice | PriceAfterDiscount |
4506 | 23 | 268 | 268 |
4506 | 54 | 226 | 226 |
4506 | 12 | 145 | 72,5 |
Total | 639 | 566,5 |
Problem is confusing, yes. But you know what is making this more difficult is the changing requirement. It seem you/your user are building onto the problem. It would be easier if we know the whole issue and try to resolve it instead of breaking it down.
Anyways, try this
Table:
LOAD SubId,
ProdId,
Fullprice as FullPrice,
DiscountPrice,
FinalPrice
FROM
[C:\Users\talwars\Downloads\DiscountProd.xlsx]
(ooxml, embedded labels, table is Blad1);
FinalTable:
LOAD *,
If(SubId = Previous(SubId), RangeSum(Peek('CountProdId'), 1), 1) as CountProdId,
If(If(SubId = Previous(SubId), RangeSum(Peek('CountProdId'), 1), 1) <= 2, DiscountPrice, FullPrice/2) as PriceAfterDiscount
Resident Table
Order By SubId, DiscountPrice desc;
DROP Table Table;
Hi Sunny,
after business has decided how to apply the new business rules I was able to solve the problem with a couple of modifications to your example.
It was a huge help so thanks for that!
I've accepted your reply as the solution.