Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Dear everyone,
I have 2 tables below:
Customer
ID | Name |
1 | A |
2 | B |
3 | C |
Opportunity
ID | Customer_ID | Status | Created Date |
1 | 1 | Won | 10/10/2022 |
2 | 1 | Lost | 25/10/2022 |
3 | 2 | Won | 13/10/2022 |
4 | 2 | Won | 23/10/2022 |
5 | 3 | Lost | 13/10/2022 |
6 | 3 | Won | 23/10/2022 |
2 table relationship by: Customer.id = Opportunity.Customer_id
Now I want to create a column "Last Opp Status" at the Customer table like below:
ID | Name | Last Opp Status |
1 | A | Lost |
2 | B | Won |
3 | C | Won |
It will take the status of the latest opportunity (created date or ID of Opportunity)
Please show me, how can I do that.
Thank you, everyone
Solved! Go to Solution.
Hi @hoanganhep ,
You could create a column as below:-
last opp status =
VAR latest_date =
CALCULATE (
MAX ( opportunity[Created Date] ),
FILTER ( opportunity, opportunity[Customer_ID] = Customer[ID] )
)
RETURN
CALCULATE (
MAX ( opportunity[Status] ),
FILTER (
ALL ( opportunity ),
opportunity[Customer_ID] = Customer[ID]
&& opportunity[Created Date] = latest_date
)
)
Output:-
BR,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Hi @hoanganhep ,
You could create a column as below:-
last opp status =
VAR latest_date =
CALCULATE (
MAX ( opportunity[Created Date] ),
FILTER ( opportunity, opportunity[Customer_ID] = Customer[ID] )
)
RETURN
CALCULATE (
MAX ( opportunity[Status] ),
FILTER (
ALL ( opportunity ),
opportunity[Customer_ID] = Customer[ID]
&& opportunity[Created Date] = latest_date
)
)
Output:-
BR,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Thank you, sir, this is what I looking for.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |