Forum Discussion
Count days between two dates, conditional based on another table
- 3 years ago
Try
Num school days = SUMX( Student, var StartDate = Student[Current Entry Date] var EndDate = MIN( TODAY(), Student[Current Exit Date] ) return CALCULATE( COUNTROWS( 'Date' ), 'Date'[Date] >= StartDate && 'Date'[Date] <= EndDate, 'Date'[Type] = "School day" ) ) - 3 years ago
Hi , ambere
According to your description , you want to calculate school days enrolled by using the start and end date in table 1 (end date should be either end date or today, whichever is sooner.)
Here are the steps you can follow:
(1)My test data is the same you provided.
(2)We can create a calculated column :
Days = var _exitdate=IF([Current Exit Date]>TODAY(),TODAY(),[Current Exit Date]) return COUNTROWS(FILTER(Sheet1,'Sheet1'[Date]>=[Current Entry Date]&&'Sheet1'[Date]<=_exitdate&&'Sheet1'[Type]="School Day"))(3)Then we can meet your need , the result is as follows:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi , ambere
According to your description , you want to calculate school days enrolled by using the start and end date in table 1 (end date should be either end date or today, whichever is sooner.)
Here are the steps you can follow:
(1)My test data is the same you provided.
(2)We can create a calculated column :
Days =
var _exitdate=IF([Current Exit Date]>TODAY(),TODAY(),[Current Exit Date])
return
COUNTROWS(FILTER(Sheet1,'Sheet1'[Date]>=[Current Entry Date]&&'Sheet1'[Date]<=_exitdate&&'Sheet1'[Type]="School Day"))
(3)Then we can meet your need , the result is as follows:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- ambere3 years agoRegular Visitor
Thank you! This works, in addition to the other solution posted.
Sorry for my delayed reply. I couldn't figure out how to log back in here. Yikes!