Rank show the max name and not ID

Hi I have the below calculated field that shows the agency with the max approved amount partitioned by these fields.
But I want to show in the visual not the agency ID but the agency name.
How to do so?

ifelse(
    rank(
        [sum({Approved Amount}) DESC], 
        [{Expense Name}, { ID}, {Product Size}, {Product Type}]
    ) = 1,
    max({Agency ID}),
    NULL
    )

Hi @pantelis,
I replied recently to another one of your questions that was similar to this when dealing with a max calculated field:

Let me know if that helps for this case as well.

But additionally, if you’d like to return the Agency name; why are you adding your ‘Agency ID’ to the calculated field instead of ‘Agency Name’?

Hi @Brett

Because If I add the agency name without max I get the Mismatch aggegation error and if I add it with max it doesnt work because it is a string field. How can I add the agency name in the below formula?

ifelse(
rank(
[sum({Approved Amount}) DESC],
[{Expense Name}, { ID}, {Product Size}, {Product Type}]
) = 1,
max({Agency ID}),
NULL
)

Hi @pantelis,
In regards to your calculated field; since you’re already reducing it down to only show rank equaling 1, you shouldn’t need the additional ‘max’ as you’ll already only be returning one value. Try removing the max and let me know if it works.

Hi @pantelis,
It’s been awhile since we last heard from you, following up to see if you had any additional questions regarding your initial post?

If we do not hear back within the next 3 business days, I’ll close out this topic.

Thank you!

Hi @pantelis,
Since we have not heard back, I’ll go ahead and close out this topic. However, if you have any additional questions, feel free to create a new post in the community and link this discussion for relevant information if needed.

Thank you!