Limit Total Sum For Unique Items (Steve I'm Looking At You)

Let’s say I have a fruit store and there’s a deal where if a customer buys enough of any one fruit, the total price cannot exceed $150. For example, a customer could buy 50 strawberries for a total of $50 but if they buy 200 strawberries, the price is capped at $150. However, their purchase could include a variety of different fruits so the cap only kicks in if the sum for any unique fruit exceeds $150.

I created an expression that works but once there are a lot of items in a list, the processing time is crazy and often the app throws up an error/window freezes. Is there a better way of doing this?

IFS(
SUM(SELECT(Fruit[Price],
AND(
[Category Id] = [_THISROW].[Category Id],
[Fruit ID] = [_THISROW].[Fruit ID])))>150.00,
DECIMAL(
150.00/
COUNT(SELECT(Fruit[Price],
AND(
[Category Id] = [_THISROW].[Category Id],
[Fruit ID] = [_THISROW].[Fruit ID],
[In Stock] = True)))
)
)

0 9 211
9 REPLIES 9
Top Labels in this Space