Forum Discussion
Tob_P
Helper V
1 year agoCalculated column - two values, only return the last value
Hi, I would like to created a calculated column to return the last value in the Cust No column based on the lastest posting date. So in the example you can access through the link, the new column...
- Anonymous1 year ago
Hi Tob_P
Thank you very much powerbiexpert22 for your prompt reply.
Try this:
LastCustNo = VAR LatestDate = CALCULATE( MAX('Sales'[Posting Date]), ALLEXCEPT('Sales', 'Sales'[Reporting Cust No]) ) RETURN CALCULATE( MAX('Sales'[Cust No]), FILTER( 'Sales', 'Sales'[Posting Date] = LatestDate && 'Sales'[Reporting Cust No] = EARLIER('Sales'[Reporting Cust No]) ) )Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
1 year agoNot applicable
Hi Tob_P
Thank you very much powerbiexpert22 for your prompt reply.
Try this:
LastCustNo =
VAR LatestDate =
CALCULATE(
MAX('Sales'[Posting Date]),
ALLEXCEPT('Sales', 'Sales'[Reporting Cust No])
)
RETURN
CALCULATE(
MAX('Sales'[Cust No]),
FILTER(
'Sales',
'Sales'[Posting Date] = LatestDate &&
'Sales'[Reporting Cust No] = EARLIER('Sales'[Reporting Cust No])
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Tob_P
Helper V
1 year agoAnonymousPerfect - works a treat for me so thank you so much.