Last Value function

hello
i have a table in Quicksight and one column is product name order is category . i have some product with the same name but one has a category and the other one is null .i wrote this calculated field to get the last value but i face error .

ifelse({pim_category}= NULL ,lastValue({pim_category},[{product_name} DESC],[{product_name} ]),{pim_category})

and error is Mismatched aggregation. Custom aggregations can’t contain both aggregated and nonaggregated fields, in any combination.

Hello @henihennin93 - Welcome to the community! Thank you for posting your query. Can you please share a sample of your dataset and your expected output so that we can replicate the scenario at our end and share some thoughts potentially. Thank you!