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 September 15. Request your voucher.

Reply
jmeza1
Regular Visitor

Measure to confirm date in one table is between dates in another table

Hello,

 

I have two tables, Certification and Award. Neither have unique values. 

 

Certification has the following columns: 

Address NumberAlpha NameEffective DateExpiration DateCertification

 

Award has the following columns:

Address NumberOrder Number

Award Date

 

I am trying to show a column in Award that filters for the Address Number in Certification and confirms that the Award Date is between the Effective Date and the Expiration Date. Whether this is done as a true/false statement or a lookup of the Certification is fine. I think I need a measure but I can only get as far as confirming the Address Number in Award exists in Certification but cannot figure out the date compare. Please assist! Thanks

1 ACCEPTED SOLUTION

Hi @jmeza1,

 

Create a calculated table.

Cross Join Table =
VAR temp =
    ADDCOLUMNS (
        FILTER (
            CROSSJOIN (
                SELECTCOLUMNS (
                    Award,
                    "Address Number", Award[Address Number],
                    "Award Date", Award[Award Date]
                ),
                SELECTCOLUMNS (
                    certification,
                    "Address Number2", certification[Address Number],
                    "Effective Date", certification[Effective Date],
                    "Expiration Date", certification[Expiration Date]
                )
            ),
            [Address Number] = [Address Number2]
        ),
        "Check", IF (
            [Award Date] >= [Effective Date]
                && [Award Date] <= [Expiration Date],
            1,
            0
        )
    )
RETURN
    GROUPBY (
        temp,
        [Address Number],
        [Award Date],
        "check2", SUMX ( CURRENTGROUP (), [Check] )
    )

1.PNG

 

Add a calculated column in Award table.

Column =
IF (
    LOOKUPVALUE (
        'Cross Join Table'[check2],
        'Cross Join Table'[Address Number], Award[Address Number],
        'Cross Join Table'[Award Date], Award[Award Date]
    )
        > 0,
    TRUE (),
    FALSE ()
)

2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

4 REPLIES 4
MFelix
Super User
Super User

Hi @jmeza1,

 

Taking into account that both your tables don't have unique values how do you know to wich of the Address number you are refering and that the result is what you want?

 

If you have adress number 1 with two certifications starting and ending on the dates below:

 

Start: 01/01/2018 End: 30/06/2018

Start: 04/09/2018 End: 20/10/2018

 

What result would you want for the date of 30/04/2018 just true because it enters on the first date or do you want to return the certification number?

 

Just want to clarify better what you need.

 

can you provide sample data and expected result also.

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Here is an example of certification

 

Address NumberCertificationEffective DateExpiration Date
1111SSBE4/19/20137/31/2019
1116FWBE2/1/20106/20/2013
1116SSBE12/28/200812/31/2009
1116SSBE2/2/20102/29/2012
1129SMBE1/1/20119/9/2015
1129SSBE8/15/20027/31/2004
1129SSBE2/21/20087/31/2009
1129SSBE4/15/20103/31/2012
1129SSBE8/3/20048/31/2006
1129SSBE9/1/19958/31/1997
1129SWBE9/1/20119/9/2015

 

Here is an example of Award

 

Address NumberOrder NumberContract AmountAward Date
    
11112127603030607/31/2018
11112225401007/1/2018
1111212540018001/6/2016
111121254001-7.57/1/2016
11112127603032755/18/2017
111122254010480005/1/2017
1116214069228711/27/2012
1116214069-127212/21/2013
1116214069153937.957/12/2012

 

Looking at your response, I guess the need is (if this is possible) is this:  for every address number in Award confirm the Award Date falls in between the Effective Date and Ending Date of the first matching Address Number in Certification. If the Award Date does not fall in between those dates then move to the next match Address Number and so forth until there is a match. When there is a match, return the certification value. If there are no matches, return nothing (or zero). 

Hi @jmeza1,

 

Create a calculated table.

Cross Join Table =
VAR temp =
    ADDCOLUMNS (
        FILTER (
            CROSSJOIN (
                SELECTCOLUMNS (
                    Award,
                    "Address Number", Award[Address Number],
                    "Award Date", Award[Award Date]
                ),
                SELECTCOLUMNS (
                    certification,
                    "Address Number2", certification[Address Number],
                    "Effective Date", certification[Effective Date],
                    "Expiration Date", certification[Expiration Date]
                )
            ),
            [Address Number] = [Address Number2]
        ),
        "Check", IF (
            [Award Date] >= [Effective Date]
                && [Award Date] <= [Expiration Date],
            1,
            0
        )
    )
RETURN
    GROUPBY (
        temp,
        [Address Number],
        [Award Date],
        "check2", SUMX ( CURRENTGROUP (), [Check] )
    )

1.PNG

 

Add a calculated column in Award table.

Column =
IF (
    LOOKUPVALUE (
        'Cross Join Table'[check2],
        'Cross Join Table'[Address Number], Award[Address Number],
        'Cross Join Table'[Award Date], Award[Award Date]
    )
        > 0,
    TRUE (),
    FALSE ()
)

2.PNG

 

Best regards,

Yuliana Gu

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

Looks like it is working! Thanks!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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