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
Black_magic100
Helper III
Helper III

How to compare dates of two different columns in two different tables?

I have two tables: Bookings and Users.

 

They are related through CustuserID from the Bookings table and UserID from the Users table.

 

I would like to create a boolean column (true or false) to for whether or not a row from the Users table is BEFORE a row in the Bookings table.  If it is then True and vice versa.

 

The fields I am comparing are Users.MemberSince and Bookings.BookingDate.  If the User is indeed a member and they became a member BEFORE the booking date I need to filter them out as those are customers who have already converted.

1 ACCEPTED SOLUTION

Hi @Black_magic100

Create measures

Measure =
IF (
    MAX ( Bookings[BookingDate] ) = BLANK (),
    "null",
    CALCULATE ( MAX ( Bookings[BookingDate] ), ALLEXCEPT ( Users, Users[UserID] ) )
)

Measure 2 =
IF (
    MAX ( Users[MemberSinceDate] ) = BLANK ()
        || MAX ( Users[MemberSinceDate] ) >= [Measure],
    0,
    1
)


16.png

 

Add [Measure 2] in the visual level filter.

 

Best Regards
Maggie



Community Support Team _ Maggie Li
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

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

Share some data (of both Tables) that can be pasted by me in an Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Okay I will just keep it simple...

 

Users:

FirstName: Denis, Amanda, Paige

UserID: 1, 2, 3

MemberSinceDate: Thursday, December 21, 2017, Null, Null

MemberSinceTIme: 12:00:00 AM

 

Bookings:

CustUserID: 1, 2, 3

BookingDate: Thursday, January 10, 2019

BookingTime: 12:00:00 AM

 

If done right, only Amanda and Paige should show.  The MemberSinceDate and MemberSinceTime need to be BEFORE (less than) the BookingDate and BookingTime respectively.  Please keep in mind that the users I would like to show will not always be Null.  It is possible to have a MemberSince date after the BookingDate as those are the people who converted right after their session and thus I would like to track them.

 

 

Hi @Black_magic100

Create measures

Measure =
IF (
    MAX ( Bookings[BookingDate] ) = BLANK (),
    "null",
    CALCULATE ( MAX ( Bookings[BookingDate] ), ALLEXCEPT ( Users, Users[UserID] ) )
)

Measure 2 =
IF (
    MAX ( Users[MemberSinceDate] ) = BLANK ()
        || MAX ( Users[MemberSinceDate] ) >= [Measure],
    0,
    1
)


16.png

 

Add [Measure 2] in the visual level filter.

 

Best Regards
Maggie



Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.