Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
kunkumnaveen
Specialist
Specialist

How to find max value and Minvalue

Hello All,

I need to find Max Year value  and Min year value  for Each  combination of  Product,Model,Mission,Type...

For example in below sample data set 

ProductModelMissionTypeYearValues
DRA4WD ATATSel20111923
DRA4WD ATATSel20121923
DRA4WD ATATSel20131923
DRA4WD ATATSel20141932
DRA4WD ATATSel20151950
DRA4WD ATATSel20161950
DRA4WD ATATSel20171950
UTIFASSMTline2012705
UTIFASSMTline2013705
UTIFASSMTline2014725
UTIFASSMTline2015725
UTIFASSMTline2016725
UTIFASSMTline2017725
UTIFASSMTline2018725
UTIFASSMTline2019727

 

Measure i wrote  to get max and Min

1 )Max :    Only({<Year={$(=max(Year)}>}Values)

2)Min :  Only({<Year={$(=min(Year)}>}Values)

I am getting error 

Capture.PNG

 

Output:

Max value for 1st row is 1950 (Max year =2017)

Max value for 2nd row is 727 (Max year =2019)

 

PFA..

 

Thanks

Naveen

1 Solution

Accepted Solutions
sunny_talwar

May be this

Pow(
(FirstSortedValue(Values, -Year)/FirstSortedValue(Values, Year)),
1/(Max(Year)-Min(Year))-1
)

View solution in original post

8 Replies
sunny_talwar

Try this instead

For Max

FirstSortedValue(Values, -Year)

For Min

FirstSortedValue(Values, Year)
kunkumnaveen
Specialist
Specialist
Author

Thanks Sunny ,
What i am trying to achieve is a CAGR value and the formula is below ...
Pow(
(
only({<Year={$(=max(Year))}>}Values)

/
only({<Year={$(=Min(Year))}>}Values)
),
1/(Max(Year)-Min(Year))-1
)

so how to fit firstsortvalue in the place of max Year and Min Year
sunny_talwar

May be this

Pow(
(FirstSortedValue(Values, -Year)/FirstSortedValue(Values, Year)),
1/(Max(Year)-Min(Year))-1
)
sunny_talwar

Check this out

image.png

kunkumnaveen
Specialist
Specialist
Author

Thanks Sunny , when ever there is a show stopper , u always bring me out of that , i am keep learning from you ...
Once again Thanks Man
kunkumnaveen
Specialist
Specialist
Author

Need a suggestion how to add default selection value in firstsortvalue 

I mean My default  it should take 

Feature = CC

as Shown below 

Before Feature column Selection 

Capture.PNG

 

After feature Column selection Capture3.PNG

Capture2.PNG

I tried this

Pow(
(FirstSortedValue({<Feature={'CC'}>}Values, -Year)/FirstSortedValue({<Feature={'CC'}>}Values, Year)),
1/(Max({<Feature={'CC'}>}Year)-Min({<Feature={'CC'}>}Year))-1
)
kunkumnaveen
Specialist
Specialist
Author

Need a suggestion how to add default selection value in firstsortvalue 

I mean My default  it should take 

Feature = CC

as Shown below 

Before Feature column Selection 

Capture.PNG

 

After feature Column selection Capture3.PNG

Capture2.PNG

I tried this

 

Pow(
(FirstSortedValue({<Feature={'CC'}>}Values, -Year)/FirstSortedValue({<Feature={'CC'}>}Values, Year)),
1/(Max({<Feature={'CC'}>}Year)-Min({<Feature={'CC'}>}Year))-1
)

 

sunny_talwar

May be this

If(GetSelectedCount(Feature) = 0,

Pow(
(FirstSortedValue({<Feature={'CC'}>}Values, -Year)/FirstSortedValue({<Feature={'CC'}>}Values, Year)),
1/(Max({<Feature={'CC'}>}Year)-Min({<Feature={'CC'}>}Year))-1
),

Pow(
(FirstSortedValue(Values, -Year)/FirstSortedValue(Values, Year)),
1/(Max(Year)-Min(Year))-1
)
)