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

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.

Reply
Anonymous
Not applicable

Periods of time with start/stop dates in separate tables

Hi everyone!

 

Super new to Dax so I'm pretty sure I'm missing some obvious stuff... 

 

I have three separate tables with dates/times for two distinct events (A and B).

The table ares all related via the "Id" (but one Id can have more than one event A, and more than one event B).

 

So first question, how do I manage the relationships between these tables?

 

Second question, I would like to find a way to maybe merge tables Start A and End A in a way that would give me a row for each single event A.

 

And that should help me answer my main question - for context, each event B should be "contained" within one event A. I need to highlight any event B that is not in one event A.

 

Let's say A is me (Id xxx) using my badge to come in and out of work, and B is me (Id xxx) using the work delivery vehicle. If in my data there is an instance of me using the vehicle for a period that starts before I came in to work and/or ends after I left, then something is wrong. My goal here is to highlight such instances (if it's at all possible...)

 

Thank you so much in advance!!

 

Table Start A

 

IdStart date Event AStart time Event A
P-200-E01-20118-Jan-1810:30
P-200-E01-20224-Jan-1811:30
P-200-E01-2074-Jun-1816:12
P-200-E02-20316-Oct-179:00
P-200-E02-20317-Oct-1710:30
P-200-E02-20415-Dec-1710:50
P-200-E02-20531-Jan-189:00
P-200-E02-20531-Jan-1810:00
P-200-E03-20110-Oct-1712:30
P-200-E03-20113-Oct-179:00
P-200-E03-20113-Oct-179:50
P-200-E03-20114-Oct-1710:00
P-200-E03-20115-Oct-1715:00
P-200-E03-20124-Oct-1710:15
P-200-E04-20213-Nov-17 
P-200-E05-20120-Apr-1816:25
P-200-E06-2018-Dec-1712:44
P-200-E07-20128-Nov-1715:30
P-200-E07-20128-Nov-1716:45

Table End A

 

IdEnd date Event AEnd time Event A
P-200-E01-20229-Jan-1813:00
P-200-E01-2078-Jun-18 
P-200-E02-20317-Oct-1710:00
P-200-E02-20326-Oct-1715:10
P-200-E02-20415-Dec-1710:55
P-200-E02-20531-Jan-189:45
P-200-E02-2051-Feb-1817:00
P-200-E03-2012-Jan-0014:30
P-200-E03-20113-Oct-178:50
P-200-E03-20113-Oct-179:40
P-200-E03-20114-Oct-179:50
P-200-E03-20117-Oct-1714:30
P-200-E05-20120-Apr-1817:10
P-200-E06-20122-Dec-17 
P-200-E07-20128-Nov-1716:15
P-200-E07-20127-Dec-1715:50

 

 

Table B (start and end date are assumed to be the same)

 

 

IdEvent B dateEvent B start timeEvent B end time
P-200-E01-20224-Jan-1812:2512:44
P-200-E01-20224-Jan-1816:3017:12
P-200-E01-20226-Jan-1814:2314:51
P-200-E02-20316-Oct-1710:1110:32
P-200-E02-20324-Oct-177:157:31
P-200-E02-20324-Oct-1711:1311:29
P-200-E02-20324-Oct-1715:0015:20
P-200-E02-20531-Jan-1810:4511:00
P-200-E02-20531-Jan-1814:0514:50
P-200-E03-20110-Oct-1713:2013:47
P-200-E03-20110-Oct-1713:3913:47
P-200-E03-20110-Oct-1718:0018:32
P-200-E06-2018-Dec-1712:4713:16
P-200-E06-2018-Dec-1716:0516:31
P-200-E07-20129-Nov-1717:0018:05
P-200-E07-20130-Nov-1711:5512:20
P-200-E07-20130-Nov-1715:1015:29
2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

For your first question, please refer to the below steps:

 

1. You could Append Table Start A and Table B as a new table.

2. Click ID and remove other columns

3. remove duplicate rows in ID column then you will get the distinct ID.

 

Then you could create the replationship between table A and ID table with (one to Many) in Relationship view.

 

For your second question, you could merge the Table Start A and Table End A as a new query and expand the table without Id.

 

merge.PNG

 

For your further requirement, I'm still a little confused, if the above steps could solved your the first two question, please share the desired output for your last requirement.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks so much Cherry!

 

I followed your steps and they don't exactly give me what I need, BUT I learned about appending and merging and that is definitely going to be useful in general so thanks for that!

 

Here is the result for one Id. Ideally I should find a way to remove rows 2 and 3, which would leave me with one Event A from 10/16 9AM to 10/17 10AM and another event A from 10/17 10:30AM to 26/10 3:10PM.

example.PNG

Once I have all my events A defined, I need to check that all events B for the same Id happen during one event A.

 

I guess my end requirements are a bit confusing because I'm trying to use PBI to clean my data rather than report on it. I'd like for the end result to point out stuff that doesn't make sense so I can correct that before doing actual reporting.

 

I wouldn't be surprised if I was told it's just not possible but I thought I'd give it a try Smiley Very Happy

 

Thanks again!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.