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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
E_K_
Helper III
Helper III

Nested IF troubleshooting

Hi, working on a calculated column to return "During", "Outside", "7 days pre" or "7 days post" to see if an [ID] from table 'Incidents' has a start time that falls inside or outside [7 days pre] or [7 days post].

 

During is defined as falling in between [Start Time] and [End Time].  [Start Time], [End Time], [7 days pre] and [7 days post] all exist in a related table 'Freezes'

 

Here's the code, it however won't return Outside whatever I do to play around with it. Have tried split into 2 columns to recalculate if outside in a separate column. 

 

Help! (I will not share a sample data model as that is not required here) 

When5 =
VAR IncidentFreezes = ALL('Freezes')
VAR IncidentFreeze = CALCULATE(
    MAX('Freezes'[Start Time]),
    FILTER(
        IncidentFreezes,
        'Freezes'[7 days pre] <= 'Incidents'[I.Start Time] && 'Freezes'[7 days post] >= 'Incidents'[I.Start Time]
    )
)
RETURN
    IF(
        'Incidents'[I.Start Time] >= MIN('Freezes'[7 days post]) && 'Incidents'[I.Start Time] >= MAX('Freezes'[End Time]),
        "Outside",
        IF(
            'Incidents'[I.Start Time] >= MIN('Freezes'[Start Time]) && 'Incidents'[I.Start Time] < MAX('Freezes'[End Time]),
            "During",
            IF(
                'Incidents'[I.Start Time] >= MIN('Freezes'[7 days pre]) && 'Incidents'[I.Start Time] < MIN('Freezes'[Start Time]),
                "7 days pre",
                IF(
                    'Incidents'[I.Start Time] <= MAX('Freezes'[7 days post]) && 'Incidents'[I.Start Time] >= IncidentFreeze,
                    "7 days post",
                    IF(
                        AND(
                            ISBLANK(IncidentFreeze),
                            'Incidents'[I.Start Time] >= MAX('Freezes'[End Time])
                        ),
                        "7 days post",
                        BLANK()
                    )
                )
            )
        )
    )
 
0 REPLIES 0

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors