Y-axis labels, use id field, display title

Hello,

I have a list of users, with unique ids, but whose names can be duplicates.
i.e: Two different John Doe work for the same company.

I want to display users statistics on a stacked horizontal bar chart, and I would like to display the user names as labels on the y-axis. In an ideal scenario, the y-axis would be on the user id field, and the labels would be on the name. I could not find a way to achieve that.

As a workaround, I use a calculated field which concatenates the name and the id. But I would prefer to display clean names on the y-axis.

Any tips would be appreciated.

1 Like

Hello @Loupi, achieving your exact solution likely is not possible. There is not a way to utilize the ID field for the Y-Axis but then display the user’s name instead. What if instead of utilizing concat to merge the name with the ID, you instead used a denseRank calculation and returned a number before or after the user’s name if there is more than 1.

denseRank
(
  [{user_id} DESC],
  [{user_name}],
  PRE_AGG
)

Then you could check if there is more than 1 user_id per username and only concat the rank value when there is:

Ranked User Names = ifelse(maxOver({User Rank}, [{user_name}], PRE_AGG) > 1, concat({user_name}, ' ', toString({User Rank})), {user_name})

This would at least make the formatting of the name as clean as possible while also allowing you to show multiple users with the same name. Let me know if this helps!

2 Likes

Hello @DylanM !

Thank you for this nice tip, it works perfectly!

have a nice day! :slight_smile:

1 Like