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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
FriedWater
Frequent Visitor

Mapping time from one table to another

Hi all, so I have 2 tables, in the first table I have Start Time and End Time, in the second table I have only Time. What I wish to do is to map the Time from the second table to fit within the Start and End Time of the first table.

 

For example, from Table 1, Start Time is 13:39:46 and End Time is 13:42:04. I wish to be able to fit the Time from Table 2 that lies within these 2 timing, eg. 13:40:54 or 13:41:33. The only similar columns these 2 tables have is Date, the rest of the columns that are not shown are different between the 2 tables. 

 

Anyway that I can make this work? TIA!

 

FriedWater_1-1660656530092.png

Table 1 

 

FriedWater_2-1660656548451.png

Table 2

 

 

 

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @FriedWater ,

Please try below steps

1. my test table

Table1:

vbinbinyumsft_0-1660886048585.png

Table2:

vbinbinyumsft_2-1660886119817.png

2. add three new column to "Table2"

Start_Time = RIGHT( RELATED(Table1[Start Time]),11)
End_Time = RIGHT(RELATED(Table1[End Time]),11) 
Help =
VAR diff1 =
    DATEDIFF ( Table2[Start_Time], Table2[Time], SECOND )
VAR diff2 =
    DATEDIFF ( Table2[Time], Table2[End_Time], SECOND )
VAR a =
    IF ( diff1 > 0, 1, 0 )
VAR b =
    IF ( diff2 > 0, 1, 0 )
RETURN
    a & b

 

vbinbinyumsft_3-1660886250363.png

3. create a table visual and add a filter to this visual 

vbinbinyumsft_5-1660886362596.png

Please refer the attached .pbix file

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

1 REPLY 1
v-binbinyu-msft
Community Support
Community Support

Hi @FriedWater ,

Please try below steps

1. my test table

Table1:

vbinbinyumsft_0-1660886048585.png

Table2:

vbinbinyumsft_2-1660886119817.png

2. add three new column to "Table2"

Start_Time = RIGHT( RELATED(Table1[Start Time]),11)
End_Time = RIGHT(RELATED(Table1[End Time]),11) 
Help =
VAR diff1 =
    DATEDIFF ( Table2[Start_Time], Table2[Time], SECOND )
VAR diff2 =
    DATEDIFF ( Table2[Time], Table2[End_Time], SECOND )
VAR a =
    IF ( diff1 > 0, 1, 0 )
VAR b =
    IF ( diff2 > 0, 1, 0 )
RETURN
    a & b

 

vbinbinyumsft_3-1660886250363.png

3. create a table visual and add a filter to this visual 

vbinbinyumsft_5-1660886362596.png

Please refer the attached .pbix file

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.