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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Count/Sum Days between 2 set of Dates

Hi Everyone, I'm fairly new to Power BI and DAX. But I need my formula from Excel to be in DAX/Power BI within the next few days:

=SUM(DAYS360(A3,F3),-IF(AND(B3<F3,C3<F3),DAYS360(B3,C3),IF(AND(B3<F3,C3>=F3),DAYS360(B3,F3),0)))

 

And here's the sample Tables:

 

yreme_zner_0-1652863809274.png

 

What I basically trying to calculate in PowerBI, for example is Time To Submit, the number of Days Between Open Date and Submit but exclude the days within Hold Start and Hold End in the calculations.

 

Appreciate help on this. Thanks! 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

You can try this measure

 

Measure = 
var _v1=DATEDIFF(MIN('Table'[Open Date]),MIN('Table'[Submit]),DAY)  //DAYS360(A3,F3)
var _v2=IF(AND(MIN('Table'[Hold Start])<MIN('Table'[Submit]),MIN('Table'[Hold End])<MIN('Table'[Submit])),DATEDIFF(MIN('Table'[Hold Start]),MIN('Table'[Hold End]),DAY),IF(AND(MIN('Table'[Hold Start])<MIN('Table'[Submit]),MIN('Table'[Hold End])>=MIN('Table'[Submit])),DATEDIFF(MIN('Table'[Hold Start]),MIN('Table'[Submit]),DAY),0))  //IF(AND(B3<F3,C3<F3),DAYS360(B3,C3),IF(AND(B3<F3,C3>=F3),DAYS360(B3,F3),0))
return _v1-_v2 

 

result

vxiaotang_0-1653284282923.png

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

You can try this measure

 

Measure = 
var _v1=DATEDIFF(MIN('Table'[Open Date]),MIN('Table'[Submit]),DAY)  //DAYS360(A3,F3)
var _v2=IF(AND(MIN('Table'[Hold Start])<MIN('Table'[Submit]),MIN('Table'[Hold End])<MIN('Table'[Submit])),DATEDIFF(MIN('Table'[Hold Start]),MIN('Table'[Hold End]),DAY),IF(AND(MIN('Table'[Hold Start])<MIN('Table'[Submit]),MIN('Table'[Hold End])>=MIN('Table'[Submit])),DATEDIFF(MIN('Table'[Hold Start]),MIN('Table'[Submit]),DAY),0))  //IF(AND(B3<F3,C3<F3),DAYS360(B3,C3),IF(AND(B3<F3,C3>=F3),DAYS360(B3,F3),0))
return _v1-_v2 

 

result

vxiaotang_0-1653284282923.png

 

Best Regards,

Community Support Team _Tang

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

Anonymous
Not applicable

Thank you so much!! 😊

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors