Forum Discussion
Equipes postées
Bonjour,
J'aimerai créer un rapport journalier sur notre atelier de production.
L'atelier est organisé en 5 équipes :
du lundi au vendredi il y a 3 équipes : Matin (5h à 13h) Soir (13h à 21h) Nuit (21h à 5h). La journée a considérer est entre le début du poste matin et la fin du poste nuit (qui est a cheval sur 2 jours).
du samedi au dimanche il y a 2 équipes : Matin WE (5h à 17h) Soir WE (17h à 5h).
J'ai essayé de jouer avec mes tables de dates et de temps mais je n'arrive pas à m'en sortir. Une solution simple consisterai à pouvoir filtrer à partir d'une date au choix systématiquement à partir de 5h puis afficher les 24h dernières heures. Si quelqu'un peut m'aider à réaliser cette opération ça serai vraiment chouette !
- Anonymous3 years ago
Hi Matseign ,
Please try to use the SWITCH function with a variable that stores the time value. You can then use different cases to return different shift names based on the time value and the day of the week. For example, if you have a column called Time that contains the time values, you can create a calculated column called Shift like this:
Shift = VAR _Time = [Time] RETURN SWITCH ( TRUE (), WEEKDAY ( [Date] ) >= 2 && WEEKDAY ( [Date] ) <= 6 && _Time >= TIME ( 5, 0, 0 ) && _Time < TIME ( 13, 0, 0 ), "Morning", WEEKDAY ( [Date] ) >= 2 && WEEKDAY ( [Date] ) <= 6 && _Time >= TIME ( 13, 0, 0 ) && _Time < TIME ( 21, 0, 0 ), "Evening", WEEKDAY ( [Date] ) >= 2 && WEEKDAY ( [Date] ) <= 6 && _Time >= TIME ( 21, 0, 0 ) && _Time < TIME ( 5, 0, 0 ), "Night", WEEKDAY ( [Date] ) = 1 || WEEKDAY ( [Date] ) = 7 && _Time >= TIME ( 5, 0, 0 ) && _Time < TIME ( 17, 0, 0 ), "Morning WE", WEEKDAY ( [Date] ) = 1 || WEEKDAY ( [Date] ) = 7 && _Time >= TIME ( 17, 0, 0 ) && _Time < TIME ( 5, 0, 0 ), "Evening WE", BLANK () )This formula uses the WEEKDAY function to get the day of the week from the date column and the TIME function to create time values for comparison. It then uses the SWITCH function to return the shift name based on the conditions. If none of the conditions are met, it returns a blank value.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- AnonymousNot applicable
Hi Matseign ,
Please try to use the SWITCH function with a variable that stores the time value. You can then use different cases to return different shift names based on the time value and the day of the week. For example, if you have a column called Time that contains the time values, you can create a calculated column called Shift like this:
Shift = VAR _Time = [Time] RETURN SWITCH ( TRUE (), WEEKDAY ( [Date] ) >= 2 && WEEKDAY ( [Date] ) <= 6 && _Time >= TIME ( 5, 0, 0 ) && _Time < TIME ( 13, 0, 0 ), "Morning", WEEKDAY ( [Date] ) >= 2 && WEEKDAY ( [Date] ) <= 6 && _Time >= TIME ( 13, 0, 0 ) && _Time < TIME ( 21, 0, 0 ), "Evening", WEEKDAY ( [Date] ) >= 2 && WEEKDAY ( [Date] ) <= 6 && _Time >= TIME ( 21, 0, 0 ) && _Time < TIME ( 5, 0, 0 ), "Night", WEEKDAY ( [Date] ) = 1 || WEEKDAY ( [Date] ) = 7 && _Time >= TIME ( 5, 0, 0 ) && _Time < TIME ( 17, 0, 0 ), "Morning WE", WEEKDAY ( [Date] ) = 1 || WEEKDAY ( [Date] ) = 7 && _Time >= TIME ( 17, 0, 0 ) && _Time < TIME ( 5, 0, 0 ), "Evening WE", BLANK () )This formula uses the WEEKDAY function to get the day of the week from the date column and the TIME function to create time values for comparison. It then uses the SWITCH function to return the shift name based on the conditions. If none of the conditions are met, it returns a blank value.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.