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.
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
Solved! Go to Solution.
@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
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
Thank you - thats very very helpful 🙂
@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
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!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
99 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
111 | |
92 | |
84 | |
66 |