If I understand well your problem, you can utilise the topBottomRank aggregation function to rank the categories and then create a calculated field to group the categories not in the top 5 as “Others”. Here’s a step-by-step guide:
Create a Calculated Field for Ranking:
Navigate to the calculated fields section and create a new calculated field with the following formula:
Utilise the New Field in Your Chart:
Now, use the calculated field that groups categories as ‘Others’ on the category axis of your stacked bar chart. This should allow you to display only the top 5 categories per month and group the rest as ‘Others’.
By following these steps, you should be able to effectively manage and visualise your data in QS.
I tried to do it, but I recieved the error “Mismatched aggregation. Custom aggregations can’t contain both aggregated and nonaggregated fields, in any combination.”
The dense_rank is working, but the ifelse command doesn´t work.
I still really need help, I couldn’t make it work. When the field is created, it only works for one month, when I filter more than one month, the rank does not respect the month.
I need to rank the highest financial value divided by month and category. I’ve been trying for a week, but without success.
Try the below steps:
Step 1: Calculate category level values
Use sumOver to return same value across all months, since you are not looking at varying months
Sample calculation :
The chart I need is stacked by category. On the X axis, I need to show the months, on the y axis I need to show the value. I need to show the 5 biggest categories/values and the rest show as “others” in the same chart.
We can use the group/colour settings and set the no. of bar segments displayed as 5. Check here for sample implementation.
Just a catch, instead of adding the direct field value, create a calculated field sum(value) that will allow you to sort the value field correctly. Here is a snip to the implementation, details you can check in the same published analysis sample solution 46922
Are you still working on this or were you able to find a solution?
I think that @prantika_sinha 's example above is the closest solution but I’m not sure I totally understand the end objective. To clarify, you want a stacked bar chart with 6 segments sorted from highest to lowest, with the first 5 being actually category names and the 6th saying “Other” by month.
If the above is the case, ultimately, I don’t think there is a way to control the order of the segments in the bars via sort orders in the field well. It seems to be based on alphabetical/numeric order of the field value i.e. A, B, C, D or 1, 2, 3 etc… This topic still has what I think is the best solution: