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.
powerbiexpert22
Impactful Individual
1 year agoHi Tob_P
What is the relationship or business rule between ABC01 and HUW227
Similary, What is the relationship or business rule between GEO02 and HUW221
Tob_P
Helper V
1 year agopowerbiexpert22
A Cust No can change. To maintain reporting on a Customer, a Reporting Cust No is created to retain the original Cust No. For the purposes of this task, I need to be able to output the last Cust No based on the most recent Posting Date