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

Time interval between week days and hours

Hello. I have the following problem:

 

I have a file with a field called "PaymentDateHour" and it has date and hour format (09-12-2020 17:32:00).   I need to group my table' entries by cycles with the following logic:

 

BeginningEndCycle
Fri  11:00:00Mon 10:59:5930
Mon 11:00:00Tue 10:59:5940
Tue 11:00:00Wen 10:59:5950
Wed 11:00:00Thu 10:59:5960
Thu 11:00:00Mon 10:59:59

20

 

 

I need help to convert the date and hour format to weekday and hour format and then place in the respective cycle.

 

If a order was pay between friday 11:00:00 and monday 10:59:59 the cycle is 30 and so on. 

 

Any ideas?

 

Thanks!

 

2 ACCEPTED SOLUTIONS
AlB
Super User
Super User

Hi @Anonymous 

Cycle =
VAR cutOffT_ = 11 / 24
VAR shiftedDayTime_ = Table1[PaymentDayHour] - cutOffT_
VAR day_ =
    WEEKDAY ( shiftedDayTime_, 2 )
RETURN
    SWITCH ( day_, 1, 40, 2, 50, 3, 60, 4, 20, 30 )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

AlB
Super User
Super User

@Anonymous 

Of course it does. See it at play in the attached file.

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

3 REPLIES 3
AlB
Super User
Super User

@Anonymous 

Of course it does. See it at play in the attached file.

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

It didn't work: "An argument of function 'WEEKDAY' has the wrong data type or the result is too large or too small."

AlB
Super User
Super User

Hi @Anonymous 

Cycle =
VAR cutOffT_ = 11 / 24
VAR shiftedDayTime_ = Table1[PaymentDayHour] - cutOffT_
VAR day_ =
    WEEKDAY ( shiftedDayTime_, 2 )
RETURN
    SWITCH ( day_, 1, 40, 2, 50, 3, 60, 4, 20, 30 )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

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.

Top Solution Authors