4 Replies Latest reply: Dec 11, 2013 3:07 AM by Simon Gurney

# How to get field name out of (max(sum(xxx), 1) ... Who is the biggest?

Hi

Sorry to ask this, (i feel rather stupid that i can't work it out)...

How do i get the field name out of:

num(max(aggr(sum([SALES VALUE]), Period, [ITEM DESCRIPTION]), 1), '£#,##0')

So i can make the label "[ITEM DESCRIPTION] = £100,000"

See attached jpg.

Thanks

Simon

• ###### Re: How to get field name out of (max(sum(xxx), 1) ... Who is the biggest?

Never a question is stupid.

There are many ways, but one of the is using firstsortedvalue() function.

firstsortedvalue(ItemDesc,Aggr(Sum(Sales)))

This function sort your values and gives you the first one.  If you want to get last value, put a :

firstsortedvalue(ItemDesc,-Aggr(Sum(Sales)))

See this for a better explanation:  FirstSortedValue function in QlikView - Part I - YouTube

• ###### Re: How to get field name out of (max(sum(xxx), 1) ... Who is the biggest?

firstsortedvalue([ITEM DESCRIPTION],aggr(sum([SALES VALUE]), [ITEM DESCRIPTION], Period))

The sort weight being ... aggr(sum([SALES VALUE]), [ITEM DESCRIPTION], Period)

worked well.... sort the items by sales value by month

Thanks very much for your help

• ###### Re: How to get field name out of (max(sum(xxx), 1) ... Who is the biggest?

firstsortedvalue([ITEM DESCRIPTION],aggr(sum([SALES VALUE]), [ITEM DESCRIPTION], Period))

The sort weight being ... aggr(sum([SALES VALUE]), [ITEM DESCRIPTION], Period)

worked well.... sort the items by sales value by month

Thanks very much for your help

• ###### Re: How to get field name out of (max(sum(xxx), 1) ... Who is the biggest?

Not 100% sure I understand the question, but why don't you just concatenate the strings together? So something like:

'Item Description = ' & num(max(aggr(sum([SALES VALUE]), Period, [ITEM DESCRIPTION]), 1), '£#,##0')

Regards,