Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
eptaqlik
Contributor III
Contributor III

Last price in a period

Please someone could help me.

I want to list the last price in every period for all my material

Tks in advance.

Marco

I have this data:

  

MaterialPeriodDatePrice
A20180115/01/20185
A20180120/01/20186
A20180215/02/20187
A20180220/02/20188
B20180110/01/201820
B20180125/01/201821
B20180127/01/201822
B20180210/02/201825
B20180225/02/201824
B20180227/02/2018

23

I want this result:

  

MaterialPeriod201801201802
A68
B2223
1 Solution

Accepted Solutions
sunny_talwar

May be try this

Dimension

Material

Period

Expression

FirstSortedValue(Price, -Date)


Capture.PNG

View solution in original post

7 Replies
sunny_talwar

May be try this

Dimension

Material

Period

Expression

FirstSortedValue(Price, -Date)


Capture.PNG

sasiparupudi1
Master III
Master III

Another script based solution is

T1:

LOAD * INLINE [

    Material, Period, Date, Price

    A, 201801, 15/01/2018, 5

    A, 201801, 20/01/2018, 6

    A, 201802, 15/02/2018, 7

    A, 201802, 20/02/2018, 8

    B, 201801, 10/01/2018, 20

    B, 201801, 25/01/2018, 21

    B, 201801, 27/01/2018, 22

    B, 201802, 10/02/2018, 25

    B, 201802, 25/02/2018, 24

    B, 201802, 27/02/2018, 23

];

Left Join(T1)

LOAD

Material,

Period,

Max(Date) as Date,

1 As IsLastPrice

Resident T1

GROUP By

Material,

Period

;

sudeepkm
Specialist III
Specialist III

I strongly recommend Sunny's answer, however another way of doing it in the chart is using the below expression in a Straight or Pivot table along with Dimensions as Material and Period.

sum(if(Aggr(NODISTINCT Date(max(Date),'DD/MM/YYYY'),Material,Period) =Date,Price))

eptaqlik
Contributor III
Contributor III
Author

Hi Sunny,

many tks; it works very well.

ciao

Marco

eptaqlik
Contributor III
Contributor III
Author

Hi Sasidhar,

tks; a interesting alternative.

ciao

Marco

eptaqlik
Contributor III
Contributor III
Author

Hi Sudeep,

your note is correct; the anwer of Sunny works very well.

Also yours works very well.

ciao

Marco

sasiparupudi1
Master III
Master III

Glad that you got this working.. Please close this thread by marking a correct and  any helpful answers