Hello,
For info, I'm still pretty new with PowerPivot.
I'm trying to work out the last date a customer made a purchase as well as the penultimate date (the date before the last).
To take a simple example, let's say Tbl Sales has 3 columns:
Customer | Trandate | Qty
A | 01/01/2016 | 15
A | 02/01/2016 | 52
A | 03/01/2016 | 25
A | 04/01/2016 | 12
A | 05/01/2016 |20
B | 01/01/2016 |50
B | 03/01/2016 | 20
B | 05/01/2016 | 15
First measure:
LastSaleDate:=MAX(Sales[TranDate])
Second measure:
Penultimate1:==CALCULATE(MAX(Sales[TranDate]),FILTER(Sales,Sales[TranDate]<MAX(Sales[TranDate])))
This works fine. But I have recently learned that I can use a measure as an argument for FILTER, so I try this, based on samples found around the web and in books:
Penultimate2:=CALCULATE(MAX(sales[TranDate]),FILTER(All(Sales),Sales[TranDate]<LastSaleDate))
This returns (Blank). And I do not understand! I have been trying many days now to take the LastSaleDate and use it in the filter of the second measure but whatever I have tried has either returned blank or error.
Could anyone tell me what I do wrong here?
Thank You
Christine
For info, I'm still pretty new with PowerPivot.
I'm trying to work out the last date a customer made a purchase as well as the penultimate date (the date before the last).
To take a simple example, let's say Tbl Sales has 3 columns:
Customer | Trandate | Qty
A | 01/01/2016 | 15
A | 02/01/2016 | 52
A | 03/01/2016 | 25
A | 04/01/2016 | 12
A | 05/01/2016 |20
B | 01/01/2016 |50
B | 03/01/2016 | 20
B | 05/01/2016 | 15
First measure:
LastSaleDate:=MAX(Sales[TranDate])
Second measure:
Penultimate1:==CALCULATE(MAX(Sales[TranDate]),FILTER(Sales,Sales[TranDate]<MAX(Sales[TranDate])))
This works fine. But I have recently learned that I can use a measure as an argument for FILTER, so I try this, based on samples found around the web and in books:
Penultimate2:=CALCULATE(MAX(sales[TranDate]),FILTER(All(Sales),Sales[TranDate]<LastSaleDate))
This returns (Blank). And I do not understand! I have been trying many days now to take the LastSaleDate and use it in the filter of the second measure but whatever I have tried has either returned blank or error.
Could anyone tell me what I do wrong here?
Thank You
Christine