Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 
					
				
		
 aaronnayan
		
			aaronnayan
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
 OmarBenSalem
		
			OmarBenSalem
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		per analogy :
='Customer with the most Sales : '&firstsortedvalue (customer, -aggr( sum(sales),customer))
result :
 OmarBenSalem
		
			OmarBenSalem
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		maybe:
=firstsortedvalue ([CustomerName], -aggr( max($(vMargin)),[CustomerName]))
or
=firstsortedvalue ([CustomerName], -max(aggr($(vMargin),[CustomerName])))
 OmarBenSalem
		
			OmarBenSalem
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		per analogy :
='Customer with the most Sales : '&firstsortedvalue (customer, -aggr( sum(sales),customer))
result :
 
					
				
		
 aaronnayan
		
			aaronnayan
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi Omar its coming back with a null value
 
					
				
		
 aaronnayan
		
			aaronnayan
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Both are not working. Maybe becuase of the variable?
 OmarBenSalem
		
			OmarBenSalem
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		what's in the variable?
 
					
				
		
 aaronnayan
		
			aaronnayan
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		I have changed the name of the fields for security
sum({<SInvoiceCount = {1}>} [Marginlcc]) + sum({<SCreditC = {1}>} [Marginlcc])
 
					
				
		
 andrei_delta
		
			andrei_delta
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		hi,
you have a mistake in the formula:
sum({<SInvoiceCount = {1}>} [Marginlcc]]) + sum({<SCreditC = {1}>} [Marginlcc])
hope it helps,
Andrew
 
					
				
		
 aaronnayan
		
			aaronnayan
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		No andrew thanks for spotting that i changed it due to security
The variable works fine on its own
 OmarBenSalem
		
			OmarBenSalem
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		What if u put the expression in ur variable directly in mine?
It works?
