Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
shri
Contributor II
Contributor II

How to use first sorted value function() to add two values

I have attached some data , now in this, for example

 

ex: Material 1011 & 1012 has week = 2 (this is the case when you can select only 1 Material )

  • If i want to get the last sorted value(last value) for material 1011 i can use 

             Firstsortedvalue(Avail.qty,+Avail.qty) whose result is 510

 

  • If i want to get the last sorted value for material 1012 i can use 

            Firstsortedvalue(Avail.qty,+Avail.qty) whose result is 530

BUT 

if you select Both 1011 & 1012 Materials in filter pane The values should get Added i.e. Result = 510+530= 1040

and this is the required result but the above expression doesn't work so please guide 

Table:

 

MaterialDeli. dateweekelementsReq. qtyAvail.qty
101109-01-192A-5500
101111-01-192B10510
101209-01-192A10500
101211-01-192B30530

 

And there is 1 more case where 

firstsortedvalue (avail.qty,+avail.qty) of 1011 for week 6 is = 382 &

firstsortedvalue (avail.qty,+avail.qty) of 1012 for week 6 is = -125 

& the result when i add these two , I should get  Result = 382-125 = 257, but i am not able to get it.

Table:

MaterialDeli. dateweekelementsReq. qtyAvail.qty
101104-02-196A-2508
101105-02-196A-10498
101105-02-196A-1497
101105-02-196A-2495
101105-02-196A-5490
101105-02-196A-8482
101105-02-196A-100382
101204-02-196A40570
101205-02-196A-20550
101205-02-196A-5545
101205-02-196A-10535
101205-02-196A30565
101205-02-196A10575
101205-02-196A-700-125

 

So please help!!

 

 

 

 

2 Solutions

Accepted Solutions
sunny_talwar

Try this

Sum(Aggr(Firstsortedvalue(Avail.qty, Avail.qty), Material))

View solution in original post

shri
Contributor II
Contributor II
Author

Thank you I got the required result!! I had to make slight change in your expression

 Exp : Sum(Aggr(Firstsortedvalue(Avail.qty, Avail.qty), Material))


I have used Exp:  Sum(Aggr(Firstsortedvalue([Avail. qty], +[Avail. qty]),[Date_D.autoCalendar.Week], Material))
(since I have weeks as dimension)

View solution in original post

3 Replies
sunny_talwar

Try this

Sum(Aggr(Firstsortedvalue(Avail.qty, Avail.qty), Material))

shri
Contributor II
Contributor II
Author

It is adding the values now but in my data I have week 16 at the bottom which I have not attached &  it is giving a null value for  that week.

shri
Contributor II
Contributor II
Author

Thank you I got the required result!! I had to make slight change in your expression

 Exp : Sum(Aggr(Firstsortedvalue(Avail.qty, Avail.qty), Material))


I have used Exp:  Sum(Aggr(Firstsortedvalue([Avail. qty], +[Avail. qty]),[Date_D.autoCalendar.Week], Material))
(since I have weeks as dimension)