Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

amount for latest date

Hi,

I have below data for each Sector , I want to show the Order_Amount which belongs to last Order_Date for each Sector using Straight Table as shown below,

I am able to calculate Max_Order_date by using below formula

Max_Order_Date= Aggr(Max(Order_Date),Sector)

Data:

SectorOrder_DateOrder_Amount
CXHNN12-Jun-201620
CXHNN13-Jun-201670
CXHNN14-Jun-201610
CXHNN15-Jun-201660
CLD0P502-Jun-201610
CLD0P509-Jun-201620
CLD0P512-Jun-201690
CLD0P514-Jun-201640
CLD0P516-Jun-201650

Expected Results:

SectorMax_Order_DateOrder_Amount
CXHNN15-JUN-201660
CLD0P516-JUN-201650
1 Solution

Accepted Solutions
swuehl
MVP
MVP

Dimension:

Sector

Expressions:

=Date(Max(Order_Date))

=FirstSortedValue( Order_Amount, -Order_Date)

edit:

or if you need to aggregate your amounts:

=FirstSortedValue( Aggr(Sum(Order_Amount),Sector,Order_Date), -Aggr(Order_Date,Sector,Order_Date) )

View solution in original post

9 Replies
swuehl
MVP
MVP

Dimension:

Sector

Expressions:

=Date(Max(Order_Date))

=FirstSortedValue( Order_Amount, -Order_Date)

edit:

or if you need to aggregate your amounts:

=FirstSortedValue( Aggr(Sum(Order_Amount),Sector,Order_Date), -Aggr(Order_Date,Sector,Order_Date) )

sunny_talwar

Just to add a small point, make sure that your Date are read properly. If those are not read as date, the solution might fall apart.

For reading the dates correctly read here:

Get the Dates Right

Why don’t my dates work?

swuehl
MVP
MVP

That's true and important, Sunny!

I assumed dates are correctly interpreted, since the OP is already able to use Max(Order_Date).

sunny_talwar

Did not suggest your response to be incorrect. Just wanted to point that date is an important component

Not applicable
Author

Thanks all

Please suggest if below results display can be possible as well , sample data is same as mentioned in original post

   

SectorOrder_DateLast_Order_Amount
CXHNN12-Jun-1660
CXHNN13-Jun-1660
CXHNN14-Jun-1660
CXHNN15-Jun-1660
CLD0P52-Jun-1650
CLD0P59-Jun-1650
CLD0P512-Jun-1650
CLD0P514-Jun-1650
CLD0P516-Jun-1650
swuehl
MVP
MVP

Try

2 Dimensions:

Sector

Order_Date

1 Expression:

=FirstSortedValue( TOTAL<Sector> Order_Amount, -Order_Date)

Not applicable
Author

Hi swuehl,

It is working like charm!

Not applicable
Author

Hi swuehl,

Can you please help suggest how the expression showing expected results after including <Sector> after TOTAL

What I know is if <dimension> is mentioned after TOTAL then expression excludes the <dimension> while performing calculation so based on this above should ignore <Sector> and show the result as 50 based on <Last Order Date> i.e 16-Jun-2016  

swuehl
MVP
MVP

No, the field listed in the TOTAL<Field> list is still considered as dimension, while any other dimension is ignored (Order_Date in your example with a chart with two dimensions Sector and Order_Date).