Finding the Date with the most number of orders for every customer

How can I find the dimension with the most/least value by a particular calculated measure, partinied by another dimension?

I have this calculated field that returns the date with the most orders by a customer (phone_number):

firstValue( SHIFTDATE, [distinct_count(OrderKey) DESC],[{PHONE_NUMBER}])

When I add it to the table below:

I get this error:

If I add the {SHIFTDATE} field to the table, the table works, but now I have a row for every Shiftdate and phone number, which I don’t want.

Hello @Ali_B

Can you try adding “SHIFTDATE” (date field) under values and hide the field?

Please let me know if that helped

Thank you,
Shravya

If I do that, it works, but now every row is repeated for how many {SHIFTDATE} there are per Phone number. So this does not solve the problem