Better Script Performance with Reduce cases and Variable Dynamic with count of Categorys