Forum Discussion
Who was assigned when booking confirmed
- 1 year ago
Hi LaurenceSD ,
Thanks for reaching out to the Microsoft fabric community forum.
Perform a lookup that finds the latest AuditDateTime before the EventDateTime for each booking. This can be achieved using DAX. Here's how to approach it in DAX:
Step-by-Step in DAX:
1. Ensure relationships are set: Event Dates[BookId] → Audit Dates[BookId] (many-to-many or many-to-one depending on your model)
2. Create a calculated column on Event Dates table: This will find the TE (the assigned person) with the most recent AuditDateTime before the EventDateTime for that booking:
DAX
AssignedTEAtConfirmation =
VAR currentBookId = 'Event Dates'[BookId]
VAR currentEventTime = 'Event Dates'[EventDateTime]
RETURN
CALCULATE (
MAX('Audit Dates'[TE]),
FILTER (
'Audit Dates',
'Audit Dates'[BookId] = currentBookId &&
'Audit Dates'[AuditDateTime] <= currentEventTime
),
TOPN (
1,
FILTER (
'Audit Dates',
'Audit Dates'[BookId] = currentBookId &&
'Audit Dates'[AuditDateTime] <= currentEventTime
),
'Audit Dates'[AuditDateTime],
DESC
)
)This logic filters the Audit Dates table to only the same BookId and where the AuditDateTime is less than or equal to the EventDateTime. Then it finds the latest TOPN 1 and gets the TE value.
Note: This method works efficiently on larger datasets. If you want to display the ConsultantId or other metadata, you can follow the same logic replacing MAX('Audit Dates'[TE]) with the field you need. If your data model isn’t performing well, consider optimizing relationships or pre-aggregating in Power Query.
If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.
Thank you
LaurenceSD Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
Apologies, does this spreadsheet link help?
All the columns are as per the data and it's the column with red text i want to acheive
https://docs.google.com/spreadsheets/d/1uslv4H9R8RY5jaTxaE8g1CzNoYbLLI4O/edit?usp=drive_link&ouid=106546660908762188172&rtpof=true&sd=true
- v-dineshya1 year ago
Community Support
Hi LaurenceSD ,
Thanks for reaching out to the Microsoft fabric community forum.
Could you please provide access to spreadsheet link.
Thanks and Regards
- v-dineshya1 year ago
Community Support
Hi LaurenceSD ,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and consider giving a KUDOS. Feel free to reach out if you need further assistance.Regards,
Dinesh
- LaurenceSD1 year ago
Advocate II
Apologies, you should now be able to access the spreadsheet, data is on Sheet2