Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Display Max transaction or max tran date in calculated dimension

Hi Guys,

     Assuming i have this table.

    

CCTYPETranNoamountTranDate
K902329AB2100001/02/2010
K902329AB4100002/02/2010
K902329AB7100005/02/2010
K902330AB1100011/02/2010
K902330AB2100012/02/2010
K902330AB5100013/02/2010
K902331AC1100022/02/2010
K902331AC3100023/02/2010
K902331AC4100024/02/2010
K902331AC6100025/02/2010

I'm trying to achieve these result in calculated dimension as per below in pivot table or straight table.

1st desired result

   

CCTYPEMax(tranno)=SUM(Amount)
K902329AB73000
K902330AB53000
K902331AC64000

2nd Desired result

   

CCTYPEdate of Max(tranno)=SUM(Amount)
K902329AB05/02/20103000
K902330AB13/02/20103000
K902331AC25/02/20104000

Any idea how?

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Like this?

=FirstSortedValue(TranDate, -TranNo)

Capture.JPG

View solution in original post

11 Replies
tharanikannan
Contributor III
Contributor III

Hi Asrif,

Please use the calculated dimension for date as

=aggr(date(max(TranDate),'DD/MM/YYYY'),CCTYPE)

Calculated Dimension issue.JPG

Anonymous
Not applicable
Author

possible to show the 1st desired result? is it possible?

tresesco
MVP
MVP

Like this?

=FirstSortedValue(TranDate, -TranNo)

Capture.JPG

tresesco
MVP
MVP

Well, I missed that you wanted the same in calculated dimension, may I know the purpose of the same?

tharanikannan
Contributor III
Contributor III

I will check for the first result and update you.

tharanikannan
Contributor III
Contributor III

Hi,

Please use this in your dimension for first output

=aggr(max(TranNo),CCTYPE)Calculated Dimension issue1.JPG

Anonymous
Not applicable
Author

the first was just to get the max from the same column,

the second was actually to get the value from the max of other column.

From these scenario , I understand that both can work as we are using max of transaction date or max of transaction number. but your solution with firstsortedvalue seems the one i'm looking for.

Thanks Tresesco B and thanks to Tharani as well.

Anonymous
Not applicable
Author

This was a simple table, the actual table i have was more complicated and joined with several keys with another table. I wonder why the FirstSortedvalue or just using Max(tranno) didnt work. Those this only work when all the information is in one table and not connected to other table? ( e.g. the tranno  information is in another table and joined with CCTYPE as key. and the trandate is in another table.)

tresesco
MVP
MVP

No it's not necessary that they be in the same table. However, the association and mapping type, i.e- one-to-one/one-to-many/many-to-many matters. Without knowing about your data model it would be hard to troubleshoot. However, you could give a try with DISTINCT keyword like:

=FirstSortedValue(DISTINCT TranDate, -TranNo)