Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
shanebo3239
Helper I
Helper I

Creating Relationships based on Timestamp Range

Greetings everyone,

 

I am having an issue that is probably more of just a data design issue than a PBI issue.  Either way, I cannot figure out how to proceed.

 

Our business has lobby customers that are queued into a lobby management (think "take a number") system.  This system has a table called "history".  The main fields of concern in the history table are:

 

ProcessIDStartDateEndDateCustomerServiceCounter
107/24/2017 8:30 am07/24/2017 8:45 am12
207/24/2017 8:37 am07/24/2017 8:51 am4
307/24/2017 8:42 am07/24/2017 8:56 am7
407/24/2017 8:46 am07/24/2017 8:59 am12

 

The second table is from a customer comment card system, which runs on a tablet at each customer service counter.  The relevant table here is "surveyResults" and the fields of concern are:

SurveyIDSubmittedDateCustomerServiceCounterScore
14707/24/2017 8:42 am125
14807/24/2017 8:55 am75

 

 Essentially, what I'm trying to do is join these two tables of data based on two factors:

 

1) Location where the survey was taken (CustomerServiceCounter) and

2) surveyResults.SubmittedDate falling between history.StartDate and history.EndDate

 

In other words, I should be able to get a table or set of data that looks like this:

 

ProcessIDStartDateEndDateCustomerServiceCounterScore
107/24/2017 8:30 am07/24/2017 8:45 am125
207/24/2017 8:37 am07/24/2017 8:51 am4 
307/24/2017 8:42 am07/24/2017 8:56 am75
407/24/2017 8:46 am07/24/2017 8:59 am12 

 

 As you can see, every transaction will have a process id, a start date, an end date and a customer service counter.  But not every transaction will have a score.  Also, suffice it to say there's a lot of data in both of these tables that would be beneficial to join together that I'm not showing here for simplicity's sake.

 

I created a calculated column in the history table like the following, but no luck.  I thought if I could look up the SurveyId in the other table, I could then create a relationship between the two tables and get all of the other data I needed.  But, I just keep getting circular reference errors.  Can anyone help?

SurveyId = CALCULATE(MIN(SurveyResults[SurveyId]),FILTER(SurveyResults,SurveyResults[CustomerServiceCounter]='history'[CustomerServiceCounter] && 'history'[StartDate].[Date]<=SurveyResults[SubmittedDate].[Date] && 'history'[EndDate].[Date]>=SurveyResults[SubmittedDate].[Date]))
2 REPLIES 2
shanebo3239
Helper I
Helper I

Can anyone provide some guidance on this?  I've been trying LOOKUPVALUE() formulas today and still can't get the result I'm looking for.

Anonymous
Not applicable

I can think of a way to do this, but if and only if your submittedDate + CustomerServiceCounter columns (combined) in that survey results table is guaranteed to be unique.

 

You could expand out your time range into a duplicate row for every minute within the range, and then do an inner join to only take one of those duplicate rows for each survey result you have.

 

You could probably do this with a bit of M.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.