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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Henk50
Regular Visitor

Checking if date falls between 2 dates on different table

Hi all,

 

I've found similar topics, but it's hard to applicate this on my case;

I have two tables:


Table Contracts

Supplier       Contract version       Contract start date           Contract end date     
A11-1-202231-1-2022
A21-3-20221-4-2022
B11-1-202231-12-2022

 

Table Invoices

Supplier       Invoice date      Calculated column; contracted supplier?         
A10-1-2022Yes
A10-2-2022No
Betcetc


The calculated column; contracted supplier is the goal.

An invoice should be registered under contract, if the invoice date falls between the begin& start date of any contract of that supplier. so in above example; In the first row of the invoice table, the invoice date is 10-1-2022. 10-1-2022 is for supplier A, a date between a contract start and enddate. 10-2-2022 isn't.


With my little dax knowledge i know that i have to search the invoice date in the contractstable, whilst keeping the filter on the supplier of that invoice. But my head can't translate this into dax yet. Any ideas?

1 ACCEPTED SOLUTION
Jos_Woolley
Solution Sage
Solution Sage

Hi,

Calculated Column in Invoices table:

Contracted Supplier = 
VAR InvoiceDate = Invoices[Invoice date]
VAR Supplier = Invoices[Supplier]
RETURN
    IF(
        COUNTROWS(
            FILTER(
                Contracts,
                Contracts[Supplier] = Supplier
                    && Contracts[Contract start date] <= InvoiceDate
                    && Contracts[Contract end date] >= InvoiceDate
            )
        ),
        "Yes",
        "No"
    )

Regards

View solution in original post

2 REPLIES 2
Henk50
Regular Visitor

Thank you! this works and i can follow the calculations!

Jos_Woolley
Solution Sage
Solution Sage

Hi,

Calculated Column in Invoices table:

Contracted Supplier = 
VAR InvoiceDate = Invoices[Invoice date]
VAR Supplier = Invoices[Supplier]
RETURN
    IF(
        COUNTROWS(
            FILTER(
                Contracts,
                Contracts[Supplier] = Supplier
                    && Contracts[Contract start date] <= InvoiceDate
                    && Contracts[Contract end date] >= InvoiceDate
            )
        ),
        "Yes",
        "No"
    )

Regards

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.