Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
I have two datasets.
Dataset 1 (transactions) has the following columns:
Dataset 2 (consultants) has the following columns:
I want to add a calculated column to the first dataset which returns the consultant based on client and date match. ofcourse, the second dataset only has a date of change so the calculated column must somehow determine the most 'recent' consultant that has been working on the client.
How can I do this?
Solved! Go to Solution.
HI, @Anonymous
Sorry for my careless and misunderstanding for the issue,
and you may try to this formula as below:
Consultant = MAXX ( TOPN ( 1, FILTER ( consultants, results[Client] = consultants[Client] && results[Date] >= consultants[Starting date] ), consultants[Starting date], DESC ), consultants[Consultant] )
Regards,
Lin Li
Try something like:
Column = VAR __table = RELATEDTABLE('Table21') VAR __maxDate = MAXX(__table,[date]) RETURN MAXX(FILTER(__table,[date]=__maxDate),[consultant])
Thanks a lot for your suggestion Greg. How do you suggest I relate these tables, as there are no many-to-one relationships possible. There are many dates as there are many clients.
I do get this formula working, but it only returns the consultant with the most recent date, and only for client results in that specific month. It does not respect the client to client match.
So are the tables related or no? You should be able to do a many-to-many now with composite models. Are they related by Date? If you could share some sample data and a pic of your relationships could potentially find a better solution.
Hi Greg,
This is an example of the data (can't share the real thing). Should've mentioned I was trying to achieve this in Power Query. I don't know if the composite models are availabe there:
hi, @Anonymous
After my research, you could try this formula:
result = SUMX ( TOPN ( 1, FILTER ( SUMMARIZE ( results, results[Client], results[Date], "_transaction", CALCULATE ( SUM ( results[Transactions] ) ) ), results[Client] = consultants[Client] && results[Date] <= consultants[Starting date] ), results[Date], DESC ), [_transaction] )
Result:
here is pbix, please try it.
Best Regards,
Lin
Hi and thanks for your suggestion, I really appreciate all the ideas and input. However I don't think that your solution works for what I'm trying to achieve. The result should be that the right consultant is returned for the right date and client.
The table should be something like this:
Date Client Transactions Consultant (calculated column)
Date | Client | Transactions | Consultant (calculated column) |
1-1-2019 | Client A | 2000 | Consultant 1 |
1-1-2019 | Client B | 1500 | Consultant 2 |
3-1-2019 | Client C | 4387 | Consultant 3 |
1-6-2019 | Client A | 2433 | Consultant 2 |
HI, @Anonymous
Sorry for my careless and misunderstanding for the issue,
and you may try to this formula as below:
Consultant = MAXX ( TOPN ( 1, FILTER ( consultants, results[Client] = consultants[Client] && results[Date] >= consultants[Starting date] ), consultants[Starting date], DESC ), consultants[Consultant] )
Regards,
Lin Li
Hi Lin Li, this was a great answer and helped me to do exactly what I wanted. Thanks a lot!
User | Count |
---|---|
125 | |
106 | |
99 | |
63 | |
62 |
User | Count |
---|---|
135 | |
116 | |
101 | |
71 | |
61 |