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
Thanks for the response - doesn't quite get me what I am looking for unfortunately. It returns the last Cust No listed in the table based on the posting date eg. GEO02 is the last Cust No as there on sales on 10/12/2024 therefore the calculated column returns GEO02. I probanly should have stated that there will be hundreds of Cust Nos
- powerbiexpert221 year ago
Impactful Individual
Hi Tob_P ,
I do not see customer GEO02 in your dataset, can you please share what is the expected output with some sample data?
- Tob_P1 year ago
Helper V
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- powerbiexpert221 year ago
Impactful Individual
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