Error in calculated field (Mismatched aggregation)

I’m facing an issue while trying to display brand names associated with the lowest out-of-stock value. Here’s what I’ve attempted so far:

  1. I have a dataset containing fields such as ‘Brand’, ‘Out of Stock Value’, and others.
  2. I created two calculated fields :
  • ‘MinOutOfStockValuePerBrand’: Calculated using minOver({Out of Stock Value}, [Brand]) to find the minimum out-of-stock value per brand.
  • ‘BrandWithMinOutOfStockValue’: Initially used ifelse({Out of Stock Value} = ${MinOutOfStockValuePerBrand}, [Brand], NULL) but encountered an error due to mixing aggregated and non-aggregated fields. ( Error : Mismatched aggregation. Custom aggregations can’t contain both aggregated and nonaggregated fields, in any combination.)

Please not that BrandWithMinOutOfStockValue : should return brand name with lowest out of stock value.

Also, note that {Out of Stock Value} is a calculated field.

I want to create a visual (such as a line chart or other suitable type) that specifically displays the brand name with the lowest out-of-stock value. The calculated field that i am trying to create will be added as a measure in an already existing line chart.

Could anyone assist me in understanding the error in the calculation? Additionally, any guidance on how to correctly filter and display only the brand with the lowest out-of-stock value would be helpful.

Hello there, I assume there is a store_id in your data set. Added few calculated fields: MinOutofStockValuePerBrand, Min(The min of MinOutofStockValuePerBrand), FLAG(Y when MinOutofStockValuePerBrand=Min). Also add a filter condition FLAG=Y.

Does it work if you change your expression to be minOver({Out of Stock Value}, [Brand], PRE_AGG) ? (Notice I’ve added 3d parameter to the minOver function)

Hello @phalguni24 !

Did @Xing or @Tatyana_Yakushev 's responses help resolve this and if so could you mark their posts as a solution?

We have not heard from you in some time but you would still like to help find a solution. If we do not hear from you in 3 days this post will be archived.