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

how to get week and day from the number of days

Hi all - I was wondering how to show 30 days as "4 weeks and 2 days", instead of 4.28 weeks etc

 

Does anyone know how to do this?


Thanks in advance!

 

Dan UK

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@Anonymous 

You can put the AVERAGE inside and INT to get just the whole number to us.

Weeks/Days Avg = 
VAR _TotalDays = INT ( AVERAGE ( 'Your Table'[Days] ) )
VAR _Weeks = INT ( DIVIDE ( _TotalDays, 7 ) )
VAR _Days = MOD ( _TotalDays, 7 )
VAR _WeekString = IF ( _Weeks = 0, BLANK(), _Weeks & IF ( _Weeks = 1, " week", " weeks" ) )
VAR _DayString = _Days & IF ( _Days = 1, " day", " days" )

RETURN _WeekString & " " & _DayString

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

@Anonymous 

You can put the AVERAGE inside and INT to get just the whole number to us.

Weeks/Days Avg = 
VAR _TotalDays = INT ( AVERAGE ( 'Your Table'[Days] ) )
VAR _Weeks = INT ( DIVIDE ( _TotalDays, 7 ) )
VAR _Days = MOD ( _TotalDays, 7 )
VAR _WeekString = IF ( _Weeks = 0, BLANK(), _Weeks & IF ( _Weeks = 1, " week", " weeks" ) )
VAR _DayString = _Days & IF ( _Days = 1, " day", " days" )

RETURN _WeekString & " " & _DayString
Anonymous
Not applicable

Thank you - thats very very helpful 🙂

jdbuchanan71
Super User
Super User

@Anonymous 

Try something like this.

Weeks/Days = 
VAR _TotalDays = SUM ('Your Table'[Days] )
VAR _Weeks = INT ( DIVIDE ( _TotalDays, 7 ) )
VAR _Days = MOD ( _TotalDays, 7 )
VAR _WeekString = IF ( _Weeks = 0, BLANK(), _Weeks & IF ( _Weeks = 1, " week", " weeks" ) )
VAR _DayString = _Days & IF ( _Days = 1, " day", " days" )

RETURN _WeekString & " " & _DayString

jdbuchanan71_0-1655220644487.png

Anonymous
Not applicable

Thank you - that is incredibly helpful and will please the management team! How do I do a similar thing to show the average for all them? ie average of all indexs is 20 weeks 2 days etc

 

for example if I use AVERAGE instead of SUM I get "20 weeks 2.1253 days", how do I round that up to show it as "20 weeks 2 days"?

Thanks again!

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.