Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
sifatnabil
Specialist
Specialist

Display top customers if rank is equal

Hi all,

I have this expression to return the top customer for the latest session who had the highest count of orders (Id) -

=only(if(aggr(Rank(

count(distinct {<SessionId={'$(LatestSession)'}>}Id)),

CustName)=1,CustName))

However today, we had 2 customers with the same top count of orders (i.e. rank 1) - in this scenario this function fails. How can I amend this function to return both top ranked customers?

26 Replies
Kushal_Chawda

Full macha rahe dono

sunny_talwar

I don't have the data to be to check this kushal‌, but I will take leap of faith

swuehl
MVP
MVP

Right, Rank options ,1,1 might be better then. Maybe only the second argument is needed, if we do a numeric comparison:

=Concat(If(Aggr(Num(Rank(Count(Distinct {<SessionId={'$(LatestSession)'}>}Id)), 1),CustName)=1,CustName), ',')


or


=Concat(If(Aggr(Num(Rank(Count(Distinct {<SessionId={'$(LatestSession)'}>}Id))),CustName)<2,CustName), ',')

Haven't tested it, since my version seems to return different results than yours anyway.

MK_QSL
MVP
MVP

May be this without Rank !

=Concat(Distinct Aggr(IF(Count({<SessionId={'$(LatestSession)'}>}Id) = Max(TOTAL Aggr(Count({<SessionId={'$(LatestSession)'}>}Id),CustName)), CustName),CustName),', ')

sunny_talwar

Manish bhai aapka hee intezar tha .

sifatnabil
Specialist
Specialist
Author

stalwar1‌ why do you need num ? And yes your one worked as well - maybe both work?

sunny_talwar

I don't think Num is required, but used it against safeguarding myself. You might not need it