Forum Discussion
Calculating Days Complete In A Selected Period
I would like to calculate the number of days completed in a selected period. If current period selected, whether month, quarter or year, it would calculate up to today. If a past period is selected it would calculate the total number of days in that period. If a future period is selected that has not yet begun, it would return 0.
Example:
Current Date = 2/15/24
Selected Period = QTR1 1/1/24-3/31/24
Days Complete = 46
If QT2 selected = 0
If QTR4 (previous year) = 92
Current Date = 2/15/24
Selected Period = Feb 2024 2/1/24-2/29/24
Days Complete = 15
Selected Period = Jan 2024 1/1/24-1/31
Days Complete = 31
I hope this make sense. I can't find anything on the forums on this being done.
You can use below
PassedDays =VAR _StartDate = MIN('Table'[Date])VAR _EndDate = MAX('Table'[Date])RETURNIF(_StartDate >=TODAY(),0,IF(_EndDate >= TODAY(),DATEDIFF(_StartDate,TODAY(),DAY),DATEDIFF(_StartDate,_EndDate,DAY)))
2 Replies
- arvindsingh802Community Champion
You can use below
PassedDays =VAR _StartDate = MIN('Table'[Date])VAR _EndDate = MAX('Table'[Date])RETURNIF(_StartDate >=TODAY(),0,IF(_EndDate >= TODAY(),DATEDIFF(_StartDate,TODAY(),DAY),DATEDIFF(_StartDate,_EndDate,DAY)))- jormanFrequent Visitor
That's it!!! Tank you arvindsingh802!