Thank you both for you kind answers.
Unfortunately, i'm still not able to achieve the desired result.
Regarding @Andrew_Tate proposal, i've configured a drilldown on the user_id.
If i set average of cost on Y-axis, without collapse option, I get this:
Then, if I set collapse by Sum, the result is the sum of averages, not averages of sums as wanted. (I cannot put another image being a new user; the result is, on the column for 2023-05-23, the number 468, the sum of the average values).
Even if I switch the functions sum and average in drilldown and Y-axis, I'm still getting something else.
Moreover, the fact that I have to set a number of values feels a little bit weird. What if the maximum number isn't enough?
About @nextgen suggestion, following your instructions I end up with each bar split with user_id reference.
I see where you're coming from; my bad for not explaining it clearly enough.
What i actually need is to sum the costs for each user, so that I get the total cost for a user (composed of different services). Then, I want to average them, to get the average cost by user.
I'm probably missing something, I feel like this shouldn't be that difficult to do.
I'm thinking that maybe I could create another index with this information better organized to make it easier to create the visualization?
To be as clear as i can, what I want to achieve is equivalent to this SQL query (which I'm using to check the numerical results of my tests on Kibana):
SELECT
AVG(user_cost),
YEAR,
month
FROM (
SELECT
SUM(cost) AS user_cost,
EXTRACT (YEAR FROM service_timestamp) AS year,
EXTRACT (MONTH FROM service_timestamp) AS MONTH
FROM service_deliveries
WHERE cost IS NOT NULL
GROUP BY user_id, YEAR, MONTH
ORDER BY YEAR DESC, MONTH DESC
) DATA
GROUP BY YEAR, MONTH
ORDER BY YEAR DESC, MONTH DESC
Thanks a lot for your support!