Forum Discussion
kaledjeff
8 years agoAdvocate I
Previous Purchase
Hello, I have a list of purchase orders for all of our customers. I would like to know how to get the previous purchase order for a customer. Please keep in mind the numbers of purchase order...
- 8 years ago
Or this Calculated Column
Column = VAR myLastDate = CALCULATE ( MAX ( 'Table1'[Purchase Date] ), FILTER ( ALLEXCEPT ( Table1, Table1[Client] ), 'Table1'[Purchase Date] < EARLIER ( 'Table1'[Purchase Date] ) ) ) RETURN CALCULATE ( FIRSTNONBLANK ( 'Table1'[Purchase Order], 1 ), FILTER ( ALLEXCEPT ( Table1, Table1[Client] ), 'Table1'[Purchase Date] = myLastDate ) )
Phil_Seamark
8 years agoMicrosoft Employee
Hi kaledjeff
This calculated column is close
Previous Order (Desired Result) =
VAR myLastDate =
CALCULATE(
MAX('Table1'[Purchase Date]),
FILTER(
'Table1','Table1'[Client] = EARLIER('Table1'[Client]) &&
'Table1'[Purchase Date] < EARLIER('Table1'[Purchase Date])
)
)
RETURN CALCULATE(
MAX('Table1'[Purchase Order]),
FILTER('Table1','Table1'[Purchase Date] = myLastDate)
) kaledjeff
8 years agoAdvocate I
Thank you Phil_Seamark Zubair_Muhammad for help.
I tested the calculated column by Zubair_Muhammad and it worked like a charm.
Phil_Seamark, I will test the function and let you know.
I appreacite your help.
BR
- Phil_Seamark8 years agoMicrosoft Employee
HI kaledjeff
They are essentially the same code, except you don't actually need to use the ALLEXCEPT function. It doesn't do anything in calculated columns - so could just slow down the calculation. :)