Forum Discussion
Calculated column - two values, only return the last value
- 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.
Hi powerbiexpert22
I've updated the file with a bit more dummy data. I only included 1 example Cust No when I should have added more. In this case, because Customer No HUW227 is the latest posting date (05/12/2024), then that value is returned in the column. My expected output would be...
For ABC01 Cust No, return HUW227, for GEO02 Cust No, return HUW221
Hi 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_P1 year ago
Helper V
powerbiexpert22
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