I would like to utilize the platform as a simulation tool for my QuicksightUsers. To achieve this, I have set up three user-configurable parameters:
- KMDSlots: This parameter allows the user to specify the number of promotion slots to be allocated for the “KMD” category. The value can be set between 1 and 100 using a slider.
- KDDSlots: Similar to KMDSlots, this parameter allows the user to specify the number of promotion slots for the “KDD” category. The value can also be set between 1 and 100 using a slider.
- KWDSlots: This parameter enables the user to determine the number of promotion slots for the “KWD” category. The value can be set between 1 and 100 using a slider.
One of the key data fields I need to work with is a calculated field called “ScoringCombinedDYNWeighted”. This field is the result of a complex scoring logic already implemented in the data model.
It’s worth noting that several line items in the data set may share the same scoring value (e.g., 56, 55, 30, 30, 30, 29, 15).
I would like to create a new calculated field called “Suggested promo slot” that can dynamically assign the appropriate promotion slot based on the user-configured parameter values.
The desired behavior is as follows:
- For the first
[KMDSlots]rows (e.g., 24 rows if the parameter is set to 24), when the data is sorted by “ScoringCombinedDYNWeighted” in descending order, the “Suggested promo slot” field should be populated with the value “KMD”. - For the next
[KDDSlots]rows (e.g., 30 rows if the parameter is set to 30), starting from row 25 (since the first 24 rows were already assigned “KMD”), the “Suggested promo slot” field should be populated with the value “KDD”. - For the subsequent
[KWDSlots]rows (e.g., 50 rows if the parameter is set to 50), starting from row 56 (since the previous 55 rows were already assigned “KMD” and “KDD”), the “Suggested promo slot” field should be populated with the value “KWD”. - Any remaining rows should have a NULL value in the “Suggested promo slot” field.
I have tried various approaches to achieve this functionality, but I have not been successful so far. I would appreciate any guidance or assistance from the Quick Sight community on how to implement this requirement.
So something like that but in Quicksight language:
CASE
WHEN ROW_NUMBER() OVER (ORDER BY [ScoringCombinedDYNWeighted] DESC) <= [KMDSlots] THEN 'KMD'
WHEN ROW_NUMBER() OVER (ORDER BY [ScoringCombinedDYNWeighted] DESC) <= [KMDSlots] + [KDDSlots] THEN 'KDD'
WHEN ROW_NUMBER() OVER (ORDER BY [ScoringCombinedDYNWeighted] DESC) <= [KMDSlots] + [KDDSlots] + [KWDSlots] THEN 'KWD'
ELSE NULL
END