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
Stuznet
Helper V
Helper V

Multiple IF ISBLANK Condition

Hi,

I’m struggling create an Aging Column and handle the blank.

I created a calculated column
Aging =
VAR DaysBtwn = IF(ISBLANK([Date1]), BLANK(), IF(ISBLANK([Date2), BLANK(), ([DATE1] - [Date2]) *1.))

RETURN
IF(ISBLANK(DaysBtwn), BLANK(),
IF(AND(DaysBtwn <31, “0-30 Days”, DaysBtwn <61, “30-60 Days”, “61+ Days”)))))

How do I write this formula properly without getting an error?


Much appreciated!
1 ACCEPTED SOLUTION
ChrisMendoza
Resident Rockstar
Resident Rockstar

@Stuznet -

 

AND ( ) only takes two arguements so you'd have to nest if you wanted to go that way.

 

The following seems to work in my small sample that I created, possibly it will work for your data:

 

Aging =
VAR DaysBtwn =
    IF (
        ISBLANK ( Table1[DATE1] ),
        BLANK (),
        IF (
            ISBLANK ( Table1[DATE2] ),
            BLANK (),
            ( Table1[DATE1] - Table1[DATE2] ) * 1
        )
    )
RETURN
    IF (
        ISBLANK ( DaysBtwn ),
        BLANK (),
        SWITCH (
            TRUE (),
            DaysBtwn < 31, "0-30 Days",
            DaysBtwn < 61, "30-60 Days",
            DaysBtwn >= 61, "61+ Days"
        )
    )

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

4 REPLIES 4
Anonymous
Not applicable

 
TRY THIS
DAYSDIFF =
VAR DAYS = IF(OR(ISBLANK(Table[date1]),ISBLANK(Table[date2])),BLANK(),DATEDIFF(Table[date1],Table[date2],DAY))
RETURN IF(DAYS <31, "0-30 Days" , DAYS <61, "30-60 Days" , "61+ Days")
jsh121988
Microsoft Employee
Microsoft Employee

Try this and use && instead of AND() and || instead of OR() for cleaner code:

AgeDays = 
// If either is blank, then nDays wil be blank
VAR nDays = DATEDIFF([Date1],[Date2],SECOND) / 60 / 60 / 24

SWITCH( TRUE(),
nDays < 31, "0-30 Days",
nDays < 61, "30-60 Days",
nDays >= 61, "61+ Days",
BLANK()
)

 

 

ChrisMendoza
Resident Rockstar
Resident Rockstar

@Stuznet -

 

AND ( ) only takes two arguements so you'd have to nest if you wanted to go that way.

 

The following seems to work in my small sample that I created, possibly it will work for your data:

 

Aging =
VAR DaysBtwn =
    IF (
        ISBLANK ( Table1[DATE1] ),
        BLANK (),
        IF (
            ISBLANK ( Table1[DATE2] ),
            BLANK (),
            ( Table1[DATE1] - Table1[DATE2] ) * 1
        )
    )
RETURN
    IF (
        ISBLANK ( DaysBtwn ),
        BLANK (),
        SWITCH (
            TRUE (),
            DaysBtwn < 31, "0-30 Days",
            DaysBtwn < 61, "30-60 Days",
            DaysBtwn >= 61, "61+ Days"
        )
    )

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



@ChrisMendoza  thank you it works 🙂 

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

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.