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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
AUG7
New Member

conditional? join 2 tables

 

I have 2 tables loaded in power BI. 

 

Table 1 Observation:

ProductTimeEvent1TimeEventMinus10MinDate
LEGO Technic Volvo 6x610:45:1210:35:122021-07-07
LEGO Technic Liebherr R 980012:13:4512.03:452021-07-07
LEGO Technic RC Stunt Racer13:30:2113:20:212021-07-07
LEGO Technic Volvo 6x614:35:2113:20:212021-07-08

 

Table 2 Point of Sale:

 

ProductTimeSoldDate
LEGO Technic Volvo 6x610:43:122021-07-07
LEGO Technic Liebherr R 980012:15:452021-07-07
LEGO Technic Volvo 6x613:25:212021-07-08


Now i want another column in Table 1 which checks if
TimeSold from Table 2 'fits' between TimeEvent1 and TimeEvent2 from Table 1. The end result should look something like this:

 

ProductTimeEvent1TimeEventMinus10MinDateTimeWindow  
LEGO Technic Volvo 6x610:45:1210:35:122021-07-07True
LEGO Technic Liebherr R 980012:13:4512.03:452021-07-07False
LEGO Technic RC Stunt Racer13:30:2113:20:212021-07-07Not sold
LEGO Technic Volvo 6x614:35:2113:20:212021-07-08True

 

I am stuck at the part where i add a new 'column' in Table 1, simply don't know which DAX i should use. 

 

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@AUG7,

 

Try this calculated column in Table1Observation:

 

TimeWindow = 
VAR vProduct = Table1Observation[Product]
VAR vDate = Table1Observation[Date]
VAR vTimeEvent1 = Table1Observation[TimeEvent1]
VAR vTimeEventMinus10Min = Table1Observation[TimeEventMinus10Min]
VAR vTimeSold =
    CALCULATE (
        MAX ( Table2POS[TimeSold] ),
        Table2POS[Product] = vProduct,
        Table2POS[Date] = vDate
    )
VAR vResult =
    SWITCH (
        TRUE (),
        ISBLANK ( vTimeSold ), "Not Sold",
        vTimeSold >= vTimeEventMinus10Min
            && vTimeSold <= vTimeEvent1, "True",
        "False"
    )
RETURN
    vResult

 

DataInsights_0-1627649087785.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@AUG7,

 

Try this calculated column in Table1Observation:

 

TimeWindow = 
VAR vProduct = Table1Observation[Product]
VAR vDate = Table1Observation[Date]
VAR vTimeEvent1 = Table1Observation[TimeEvent1]
VAR vTimeEventMinus10Min = Table1Observation[TimeEventMinus10Min]
VAR vTimeSold =
    CALCULATE (
        MAX ( Table2POS[TimeSold] ),
        Table2POS[Product] = vProduct,
        Table2POS[Date] = vDate
    )
VAR vResult =
    SWITCH (
        TRUE (),
        ISBLANK ( vTimeSold ), "Not Sold",
        vTimeSold >= vTimeEventMinus10Min
            && vTimeSold <= vTimeEvent1, "True",
        "False"
    )
RETURN
    vResult

 

DataInsights_0-1627649087785.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.