# Rank show the max name and not ID

**URL:** <https://community.amazonquick.com/t/rank-show-the-max-name-and-not-id/43455>\
**Category:** Q&A\
**Tags:** calculations, Business-Intelligence-Engineer, quick-sight\
**Created:** [March 6, 2025, 3:26pm UTC](https://community.amazonquick.com/t/rank-show-the-max-name-and-not-id/43455 "2025-03-06T15:26:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pantelis](https://avatars.discourse-cdn.com/v4/letter/p/f4b2a3/32.png) [@pantelis](https://community.amazonquick.com/u/pantelis)\
**Post date:** [March 6, 2025, 3:26pm UTC](https://community.amazonquick.com/t/rank-show-the-max-name-and-not-id/43455/1 "2025-03-06T15:26:49Z")

</div>

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?

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

```

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [March 6, 2025, 7:10pm UTC](https://community.amazonquick.com/t/rank-show-the-max-name-and-not-id/43455/2 "2025-03-06T19:10:49Z")

</div>

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

> [@Max and min person over submitted amount](https://community.amazonquick.com/t/max-and-min-person-over-submitted-amount/43452):
>
> Hi, I have the below calculated field that finds the max approved amount partitioned by these fields. I also calculated the min and the avg so I have the below table. But I also want to include the agent that sent this amount. So the max agent and the min agent. I.e. in the below first line I want in the max agent columns to have Agent A that submitted the 3,869 and in the min agent column Agent B that submitted the 1,650 amount. max({Submitted Amount}, [{Expense Name},{ ID},{Product Size},…

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’?

---

<div class="post-metadata">

**Author:** ![pantelis](https://avatars.discourse-cdn.com/v4/letter/p/f4b2a3/32.png) [@pantelis](https://community.amazonquick.com/u/pantelis)\
**Post date:** [March 6, 2025, 8:13pm UTC](https://community.amazonquick.com/t/rank-show-the-max-name-and-not-id/43455/3 "2025-03-06T20:13:58Z")

</div>

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  
)

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [March 7, 2025, 8:01pm UTC](https://community.amazonquick.com/t/rank-show-the-max-name-and-not-id/43455/4 "2025-03-07T20:01:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [March 24, 2025, 9:15pm UTC](https://community.amazonquick.com/t/rank-show-the-max-name-and-not-id/43455/5 "2025-03-24T21:15:31Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [March 27, 2025, 9:28pm UTC](https://community.amazonquick.com/t/rank-show-the-max-name-and-not-id/43455/6 "2025-03-27T21:28:03Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [March 27, 2025, 9:28pm UTC](https://community.amazonquick.com/t/rank-show-the-max-name-and-not-id/43455/7 "2025-03-27T21:28:32Z")

</div>


