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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jorman
Frequent Visitor

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. 

1 ACCEPTED SOLUTION
arvindsingh802
Super User
Super User

You can use below

PassedDays =
VAR _StartDate = MIN('Table'[Date])
VAR _EndDate = MAX('Table'[Date])
RETURN
IF(_StartDate >=TODAY(),0
    ,IF(_EndDate >= TODAY(),DATEDIFF(_StartDate,TODAY(),DAY),DATEDIFF(_StartDate,_EndDate,DAY)))

If this post helps, then please consider Accept it as the solution, Appreciate your Kudos!!
Proud to be a Super User!!

View solution in original post

2 REPLIES 2
arvindsingh802
Super User
Super User

You can use below

PassedDays =
VAR _StartDate = MIN('Table'[Date])
VAR _EndDate = MAX('Table'[Date])
RETURN
IF(_StartDate >=TODAY(),0
    ,IF(_EndDate >= TODAY(),DATEDIFF(_StartDate,TODAY(),DAY),DATEDIFF(_StartDate,_EndDate,DAY)))

If this post helps, then please consider Accept it as the solution, Appreciate your Kudos!!
Proud to be a Super User!!

That's it!!!  Tank you @arvindsingh802!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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