Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
tomovangel
Partner
Partner

Aggr to get max value

Hello guys, I have a StoreID,StoreType and NetAmount columns.

I want to show the max NetAmount in a single storeID, from a single type( StoreType = S,M,L)

I tried

=max(aggr(Sum(NetAmount),StoreType = 'M',StoreID)) & chr(13) & StoreID

And it returns only a value, not the StoreID, this value belongs to.

I also tried

=FirstSortedValue(StoreID , - aggr(sum(NetAmount),StoreType = 'L')) & chr(13) & aggr(sum(NetAmount),StoreType = 'L')
But it doesn't return anything.

Any suggestions will be highly appreciated,

Thanks

1 Solution

Accepted Solutions
Anil_Babu_Samineni

Then, Try this? If not, Remove - and check before Aggr()..

FirstSortedValue(StoreID, -Aggr(Sum({<singletype = {'S','M','L'}>} NetAmount), StoreID)

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

View solution in original post

8 Replies
Anil_Babu_Samineni

What are you getting when you use this?

Max({<singletype = {'S','M','L'}>} Aggr(NetAmount, StoreID))

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
tomovangel
Partner
Partner
Author

I am getting the maximum value for the selected period,
But I am not getting which store, is with that value

patroser
Partner
Partner

Hi,

I'm not quite sure if I understood what the expected output would be.
Could you provide the sample output which is on your mind?

Anil_Babu_Samineni

Then, Try this? If not, Remove - and check before Aggr()..

FirstSortedValue(StoreID, -Aggr(Sum({<singletype = {'S','M','L'}>} NetAmount), StoreID)

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

View solution in original post

tomovangel
Partner
Partner
Author

283092 - 1014
max( NetAmount ) - ( Store ID )  ( of type L)

48 293 - 1001
max(NetAmount)- ( StoreID) ( of type S)

tomovangel
Partner
Partner
Author

This is returning the StoreID with the max value, from the chosen StoreType

I will test it for a sec, and will mark your answer correct if it works

tomovangel
Partner
Partner
Author

It works when i make 2 textboxes
1 is with your expression and it gives me StoreID
2 is with =Max({<singletype = {'S','M','L'}>} Aggr(NetAmount, StoreID)) ( and it gives me the NetAmount)

Thanks

Anil_Babu_Samineni

Awesome

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)