Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
eugeniyaromanov
Contributor III
Contributor III

Min and Max values

Hello!

I've got another question.

I need to count in a text field min and max for a price.

So basically I need to show 0.22 (pink number) as min and 48.21 (red number) as max.

But when I try to count it it always show something else.

All this numbers are not in original data, they all are calculated.

I realize than I need to count it depending on fields: MonthYear, Type and Country, but don't know how.

Here is my table:

             

MonthYearTypeCountry total Litrestotal AmountPrice
=sum(Litres) = sum(Amount) =sum(Amount)/sum(Litres)
oct-2016type1FR1'901'848.00425'740.890.22
dec-2016type1FR1'828'807.00417'415.150.23
nov-2016type1FR1'687'858.00374'598.900.22
oct-2016type2BE882'472.38673'299.210.76
dec-2016type2BE798'774.70634'574.940.79
nov-2016type2BE744'572.30558'997.410.75
dec-2016type2ES636'515.96488'581.450.77
nov-2016type2ES556'924.56400'173.860.72
oct-2016type2ES421'531.36311'164.870.74
oct-2016type2FR321'233.95278'641.320.87
dec-2016type2FR249'704.06226'250.380.91
nov-2016type2FR206'497.34176'489.080.85
dec-2016type1ES2'322.2542'316.9318.22
dec-2016type1BE1'836.0242'930.2123.38
nov-2016type1ES1'801.0037'118.2320.61
oct-2016type1ES1'393.0024'903.1517.88
oct-2016type1BE983.0047'394.9048.21
nov-2016type1BE933.0041'168.73

44.13

Original Data looks like:

     

MonthYearTypeCountryLitresAmount
oct-2016type2Belgium0,050,04
oct-2016type2Belgium0,060,04
oct-2016type2Belgium0,080,06
oct-2016type2Belgium0,090,07
oct-2016type2Belgium0,10,08
oct-2016type2Belgium0,160,13
oct-2016type2Belgium0,290,23
oct-2016type2Belgium1,160,87
oct-2016type2Belgium1,250,97
oct-2016type2Belgium1,71,32
oct-2016type2Belgium1,711,32
oct-2016type2Belgium1,741,35

etc.. there are about 22453 lines in original data.

I'll be glad to answer all questions!

BR

Eugeniya

1 Solution

Accepted Solutions
sunny_talwar

May be this

Min

=Min(Aggr(Sum(Amount)/Sum(Litres), MonthYear, Type, Country))

Max

=Max(Aggr(Sum(Amount)/Sum(Litres), MonthYear, Type, Country))

View solution in original post

13 Replies
ahaahaaha
Partner - Master
Partner - Master

Hi Eugeniya,

May be like this

total Litres:    Aggr(Sum(Num(Litres)), MonthYear, Type, Country)


total Amount:   Aggr(Sum(Num(Amount)), MonthYear, Type, Country)


Price: Aggr(Sum(Num(Amount)), MonthYear, Type, Country)/Aggr(Sum(Num(Litres)), MonthYear, Type, Country)


Regards,

Andrey

sunny_talwar

So you need this in a text box object to count the min and max Amount? So you need a text box saying 2 for min and another one for max saying count of 1?

eugeniyaromanov
Contributor III
Contributor III
Author

Hello!

Thanks for the attention!

Unfortunately, it's not what I wanted.

I need to count min and max price when I make a selection.

I need a text object with Min price (for a selection(  MonthYear, Type, Country))

and a text object with Max price.

And because I'm not very good in explanation, I colored it pink and red.

But anyway, I've tried it, didn't work

sunny_talwar

May be this

Min

=Min(Aggr(Sum(Amount)/Sum(Litres), MonthYear, Type, Country))

Max

=Max(Aggr(Sum(Amount)/Sum(Litres), MonthYear, Type, Country))

eugeniyaromanov
Contributor III
Contributor III
Author

Hello!

Yes, almost.

Min and max price.

I need one box per each.

Min should tell 0.22 (even it there are two or more).

Same for max, it should tell 48.21.

Dimension to change always MonthYear, Type and Country.

sunny_talwar

Try these

Min

=Min(Aggr(Sum(Amount)/Sum(Litres), MonthYear, Type, Country))

Max

=Max(Aggr(Sum(Amount)/Sum(Litres), MonthYear, Type, Country))

eugeniyaromanov
Contributor III
Contributor III
Author

Wow, perfect!

Thanks!

How do you do that? Every time you help, it always the right answer!

How long have you been working with Qlik?

sunny_talwar

I am glad it worked... I have been working for 2 and half years now

eugeniyaromanov
Contributor III
Contributor III
Author

Btw,

if I want another text box, where I want to put a name of Country with min and max price what to do?

If i put if statement:

=if(Min(Aggr(Sum(Amount)/Sum(Litres), MonthYear, Type, Country)), Country)

it wouldn't work..