Thank you very much for the inputs provided. I took advance of them and tried to apply them to my case, however while being very close to the solution I there still a missing piece. This is my result table (created with My Superstore just to show the example):
Concretely used Rank_unique with a parameter in order to create 3 calculated fields that calculate in turn:
Sum of top N shipping cost = Sums the shipping costs for the top N (depending on the filters). in this case the top N customers in each category of product for that ship date.
Top N shipping cost on total costs = Sums the shipping costs for the top N (depending on the filters) [i.e. the previous calculated field] and divides them for the total shipping costs of that category
Window sum of Top N ratio = Sums up the ratios created with the previous ratio (however in the view it is repeated 5 time because Table shows it for each of the top 5 customers).
However, while I would like to have the calculations exactly like this (i.e. top 5 by customer in each category) I would like Tableau to show a single datapoint and not the bars split by customers as well as in the third chart for the window sum there should be only one bar and not to repeat the same number 5 times (in which case the 2 and 3 chart should be the same and for me it is important that either the second or the third work, I did the third hoping that the window sum would have shown only an aggregate of the 5 stacks of the second chart).
The result should look like:
I attached the workbook where I created this. All the measures that I added are under "Created measures for example" folder under measures.
Workbook is missing in your reply however i don't have tableau installed in my system to help you further.
Sorry about that but the links i shared earlier are perfect.Please recheck.