# New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
Contributor III

## Set Analysis Question

Hi Guys,

Really quick

i have a KPI :

max(aggr(\$(vMargin),[CustomerName]))

Which gives the value £

I want to get the Name 'String'of the customer with the most Margin?

Thanks

1 Solution

Accepted Solutions
Partner

## Re: Set Analysis Question

per analogy :

='Customer with the most Sales : '&firstsortedvalue (customer, -aggr( sum(sales),customer))

result :

11 Replies
Partner

## Re: Set Analysis Question

maybe:

=firstsortedvalue ([CustomerName], -aggr( max(\$(vMargin)),[CustomerName]))

or

=firstsortedvalue ([CustomerName], -max(aggr(\$(vMargin),[CustomerName])))

Partner

## Re: Set Analysis Question

per analogy :

='Customer with the most Sales : '&firstsortedvalue (customer, -aggr( sum(sales),customer))

result :

Contributor III

## Re: Set Analysis Question

Hi Omar its coming back with a null value

Contributor III

## Re: Set Analysis Question

Both are not working. Maybe becuase of the variable?

Partner

## Re: Set Analysis Question

what's in the variable?

Contributor III

## Re: Set Analysis Question

I have changed the name of the fields for security

sum({<SInvoiceCount = {1}>} [Marginlcc]) + sum({<SCreditC = {1}>} [Marginlcc])

Partner

## Re: Set Analysis Question

hi,

you have a mistake in the formula:

sum({<SInvoiceCount = {1}>} [Marginlcc]]) + sum({<SCreditC = {1}>} [Marginlcc])

hope it helps,

Andrew

Contributor III

## Re: Set Analysis Question

No andrew thanks for spotting that i changed it due to security

The variable works fine on its own

Partner

## Re: Set Analysis Question

What if u put the expression in ur variable directly in mine?

It works?