Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, I am trying to create a 5th column to return me the product_description values based on the importance_weight.
This is a sample data but I would like output to be a concatenation of the [product_description] field based on the [importance_weight] column.
in this case, for sales_id ='1', the value should be: Uses MBC - chip fyx, Uses PLZ - chip xx
since they both have the same weight.
for sales_id ='2', value should be: Testing - chip xyy since the weight of 1 is > 3.
I was trying to possibly grab the min(importance_weight) and return the product_description but not working as expected.
thank you.
sales_id | product_description | importance_weight | product_date |
1 | Uses MBC - chip fyx | 2 | 1/30/2024 |
1 | Uses PLZ - chip xx | 2 | 1/30/2024 |
2 | Testing - chip xyy | 1 | 12/5/2023 |
2 | Uses KTX - brd423 | 3 | 12/6/2023 |
Hello,
Utilizing the aggr function is possible.
Simply focus on the screenshot's final column.
I hope you can use this.
Concat(
Aggr(
If(
importance_weight = Min(total <sales_id> importance_weight),
product_description
),
product_description, sales_id
),
', '
)
Thank you for your assistance. It is working as expected but is very slow on the chart expression.
Trying to apply this on the script level but having problems doing this using a temp and resident load. Thank you again.
temp1:
*,
Concat(If(
importance_weight = Min(total <sales_id> importance_weight),
product_description
),' , ') as TEST_SCRIPT_DIMENSION
RESIDENT MY_MAIN
GROUP BY product_description, sales_id
ORDER BY sales_id;