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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
LewisH
Helper II
Helper II

Calculating days between dates and ignore if blank

I have two dates in a table, Registering Day and Day out. 

 

There will always be a registering date, but not always a day out. I need to work out the average daby between but this is casuing errors beciase one of the days will be blank. I have started with something like this but can anyone guide me on how to correct it. Thanks

 

Workingdays = CALCULATE(SUM('DateKey'[IsWorkingDay]), DATESBETWEEN(DateKey[Date],'Put Away Headers'[Registering_Date],'Put Away Headers'[Day_Out])) -- Here i need to filter out blank "Day Out"

2 ACCEPTED SOLUTIONS
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @LewisH,

 

If I understand you correctly, the formula below should work in your scenario. Smiley Happy

Workingdays =
IF (
    ISBLANK ( 'Put Away Headers'[Day_Out] ),
    BLANK (),
    CALCULATE (
        SUM ( 'DateKey'[IsWorkingDay] ),
        DATESBETWEEN (
            DateKey[Date],
            'Put Away Headers'[Registering_Date],
            'Put Away Headers'[Day_Out]
        )
    )
)

 

Regards

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

 

Does this work?

 

=CALCULATE(SUM('DateKey'[IsWorkingDay]),FILTER('Put Away Headers','Put Away Headers'[Day_out]<>BLANK()),DATESBETWEEN(DateKey[Date],'Put Away Headers'[Registering_Date],'Put Away Headers'[Day_Out]))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

 

Does this work?

 

=CALCULATE(SUM('DateKey'[IsWorkingDay]),FILTER('Put Away Headers','Put Away Headers'[Day_out]<>BLANK()),DATESBETWEEN(DateKey[Date],'Put Away Headers'[Registering_Date],'Put Away Headers'[Day_Out]))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @LewisH,

 

If I understand you correctly, the formula below should work in your scenario. Smiley Happy

Workingdays =
IF (
    ISBLANK ( 'Put Away Headers'[Day_Out] ),
    BLANK (),
    CALCULATE (
        SUM ( 'DateKey'[IsWorkingDay] ),
        DATESBETWEEN (
            DateKey[Date],
            'Put Away Headers'[Registering_Date],
            'Put Away Headers'[Day_Out]
        )
    )
)

 

Regards

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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