Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
orangebloss
Creator
Creator

Returning only the highest value based on two factors

I'm needing to return the maximum size for each Maker in each Size group.

e.g. 

Maker ABC - Size Group 1 Max size =100

Maker ABC - Size Group 2 Max size =150

Maker DEF - Size group 2 Max size 200

 

I'm assuming it's some sort of aggregate function but I've tried a variety of max and range max and not quite got there - any help very much appreciated

 

SizeGroup Maker Size
1 ABC 100
2 ABC 150
2 DEF 200
2 DEF

200

2 DEF

100

Labels (3)
5 Replies
Anil_Babu_Samineni

Try like this?

Max(Total <Maker> Size)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
tresesco
MVP
MVP

Or, may be :        Max(total <SizeGroup> Size)

orangebloss
Creator
Creator
Author

@Anil_Babu_Samineni  @tresesco Sadly both of those don't return any data?

I think the situation is made difficult by having sliders and variables that determine the chart axis?

Currently this almost works but when a Vehicle OEM has more than one value in the Y axis (i.e. 2 records with the same unladen weight which is also the max value for that OEM) it doesn't return the OEM name in the measure label just a null value. 

 

Max(if([Vehicle Height (mm)]>=(v_slider_Min_Height) and [Vehicle Height (mm)] <= (v_slider_Max_Height)

and
[Vehicle Length (mm)]>=(v_slider_Min_Length) and [Vehicle Length (mm)] <= (v_slider_Max_Length)
and
[Vehicle Width (mm)]<=(v_slider_Max_Width)
and

[Unladen Weight (kg)]<=(v_slider_Max_Unladen_Weight)
and
[UKBC Ave. Efficiency (kWh/km)]<=(v_slider_Max_UKBC_efficiency)
and
[Gross Capacity (kWh)]<=(v_slider_Max_Gross_Capacity)
and
[Battery Discharge Capacity (GWh)]<=(v_slider_Max_Battery_Discharge)
and
[Usable Capacity (kWh)]<=(v_slider_Max_usable_capacity)
and
v_Passenger_Status= 'Total' and [Max. Total PAX]>=(v_Min_Passenger_Number) and [Max. Total PAX]<=(v_Max_Passenger_Number)
or v_Passenger_Status= 'Standees' and [Max. Standees PAX]>=(v_Min_Passenger_Number) and [Max. Standees PAX]<=(v_Max_Passenger_Number)
or v_Passenger_Status= 'Seated' and [Max. Seated PAX]>=(v_Min_Passenger_Number) and [Max. Seated PAX]<=(v_Max_Passenger_Number)
,
if(v_Bar_Y = 'Passengers' and v_Passenger_Status='Total' ,[Max. Total PAX],


if(v_Bar_Y = 'Passengers' and v_Passenger_Status='Seated',[Max. Seated PAX],
if(v_Bar_Y = 'Passengers' and v_Passenger_Status='Standees',[Max. Standees PAX],
if(v_Bar_Y='Length',([Vehicle Length (mm)]),
if(v_Bar_Y='Height',([Vehicle Height (mm)]),
if(v_Bar_Y='Vehicle OEM',[Vehicle OEM] ,
if(v_Bar_Y='Country of Operation',[Country of Operation],
if(v_Bar_Y='Product Category', [Product Category],
if(v_Bar_Y='No of Doors',([#Doors]),
if(v_Bar_Y='Length Group',Length_Group,
if(v_Bar_Y='Battery Supplier',[Battery Supplier],
if(v_Bar_Y='Battery Chemistry',[Battery Chemistry],
if(v_Bar_Y='Gross Capacity (kWh)',( [Gross Capacity (kWh)]),
if(v_Bar_Y='Usable Capacity (kWh)',[Usable Capacity (kWh)],
if(v_Bar_Y='UKBC Ave. Efficiency (kWh/km)',[UKBC Ave. Efficiency (kWh/km)],
if(v_Bar_Y='Vehicle Width (mm)',[Vehicle Width (mm)],
if(v_Bar_Y='GVW (kg)',[GVW (kg)],
if(v_Bar_Y='Unladen Weight (kg)',[Unladen Weight (kg)],
if(v_Bar_Y='Battery Discharge Capacity (GWh)',[Battery Discharge Capacity (GWh)],
if(v_Bar_Y='Traction System Supplier',[Traction System Supplier],
if(v_Bar_Y='Traction System Model',[Traction System Model],
if(v_Bar_Y='Wheel Size (")',[Wheel Size (")],
))))))))))))))))))))))))

tresesco
MVP
MVP

@orangebloss , the way you are handling it - might not be the best way. However, that's a different question of optimisation. Here, what I can give a hint is like - if your dimension is dynamic and coming from a variable, consider pulling the same dimension info in the expression like :
Max(total <$(vDimension)> Size)

orangebloss
Creator
Creator
Author

I'm quite sure it's not but I'm working on improving! the vDimension / v_Bar_Y and v_Bar_X are all text drop down selection variable  so how would I map that to an actual field as I've done in the script above?

 

e.g. if v_Bar_Y is 'Length' then the field to use is [Vehicle Length]