Simulation: Dynamically Allocate Promotion Slots Based on User-Configurable Parameters in Quick

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:

  1. 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.
  2. 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.
  3. 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:

  1. 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”.
  2. 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”.
  3. 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”.
  4. 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

Hi @Andrea_Weilguni, you can try to create a calculated field to dynamically assign the “Suggested promo slot” based on the sorted values of “ScoringCombinedDYNWeighted” and the user-configured parameters.

Here’s the high-level approach:

  1. Create User-Configurable Parameters:
  • Create three parameters: KMDSlots, KDDSlots, and KWDSlots, each with a slider control allowing values between 1 and 100.
  1. Add Calculated Fields:
  • Create a calculated field to determine the row number of each item when sorted by ScoringCombinedDYNWeighted in descending order.

Pseudocode (Syntax may vary) - Dense Rank Documentation

rank_dense() over (order by {ScoringCombinedDYNWeighted} desc)

Let’s name this calculated field RowNumber.
3. Create the “Suggested promo slot” Calculated Field:

  • Use a case statement in a calculated field to assign the “Suggested promo slot” based on the row number and the user-configured parameter values.Here’s the calculated field formula for the “Suggested promo slot”:

Pseudocode (Syntax may vary)

ifelse(
  {RowNumber} <= {KMDSlots}, 'KMD',
  {RowNumber} <= {KMDSlots} + {KDDSlots}, 'KDD',
  {RowNumber} <= {KMDSlots} + {KDDSlots} + {KWDSlots}, 'KWD',
  NULL
)

Let’s name this calculated field SuggestedPromoSlot.

  1. **Implementation Steps in Quick Sight:**a. Create Parameters:
  • Go to the analysis you are working on.
  • Click on Parameters in the left pane.
  • Click on Create parameter.
  • Create three parameters: KMDSlots, KDDSlots, and KWDSlots, each with the type Integer and a slider control between 1 and 100.b. Create Calculated Fields:
  • Go to Analysis → Add → Calculated field.
  • Create the RowNumber calculated field using the rank function as described above.
  • Create the SuggestedPromoSlot calculated field using the ifelse statement as described above.c. Add Controls for Parameters:
  • Click on Controls in the top menu.
  • Add a control for each parameter (KMDSlots, KDDSlots, KWDSlots) so that users can adjust the values using sliders.
  1. Validate and Use:
  • Validate the calculations by previewing the data.
  • Use the SuggestedPromoSlot field in your visualizations to display the assigned promotion slots.

Did this solution work for you? If this approach does not work, you may want custom SQL. I am marking this reply as, “Solution,” but let us know if this is not resolved. Thanks for posting your questions on the Quick Sight Community!