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
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
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.