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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Nested if and statement based on dates between

Hi, 

I'm attempting to write a nested if an statement that references 2 tables. The statement should state IF(isblank[table1criteria1]),[table1criteria2],if([table1criteria2] date is between [table2criteria] then return [table2criteria2]) otherwise if false return "Non-Reservation"

Essentially I want the formula to return a criteria based on a value in table 1 being between 2 dates in a value in table 2. It'd return a value from table 2. 

 

It won't let me reference 2 different tables. Is there another solution?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Can you provide some sample data and expected results?

From what I understand, your two tables look like

vstephenmsft_0-1650963291891.png

vstephenmsft_1-1650963299221.png

 

You could create a calculated table to judge

Table = 
ADDCOLUMNS (
    CROSSJOIN ( 'table1', 'table2' ),
    "Column",
        IF (
            [criteria1] = BLANK (),
            [criteria2],
            IF (
                [date] < [date2]
                    && [date] > [date1],
                [table2criteria2],
                "Non-Reservation"
            )
        )
)

vstephenmsft_2-1650963845266.png

 

 

Best Regards,

Stephen Tao

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

Can you provide some sample data and expected results?

From what I understand, your two tables look like

vstephenmsft_0-1650963291891.png

vstephenmsft_1-1650963299221.png

 

You could create a calculated table to judge

Table = 
ADDCOLUMNS (
    CROSSJOIN ( 'table1', 'table2' ),
    "Column",
        IF (
            [criteria1] = BLANK (),
            [criteria2],
            IF (
                [date] < [date2]
                    && [date] > [date1],
                [table2criteria2],
                "Non-Reservation"
            )
        )
)

vstephenmsft_2-1650963845266.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Anonymous , Assume you need a new column

new column =

var _cnt = maxx(filter(Table2, Table1[Date] >= Table2[Date1] && Table1[Date1] <= Table2[Date2] ) ,Table2[table2criteria2] )

return

IF(isblank[table1criteria1]),[table1criteria2] , if(not(Isbalnk(_cnt)) , _cnt , "Non-Reservation" ) )

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.