Forum Discussion
Conditional format based on start and end date
- 6 years ago
Hi Anonymous ,
Regarding your questions you can do the following:
More than 1 week
Create a measure:
Number of days = SUMX('Table';DATEDIFF('Table'[Schedule Start date];'Table'[Schedule End date];DAY)) + 1Adjust your previous measure to:
Day of the week calculation = IF ( [Number of days] > 7; 1; IF ( WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > MAX ( 'Weekdays'[ID] ) || WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < MAX ( 'Weekdays'[ID] ); 0; 1 ) )Assuming you want to have all days ocupied correct?
Making use of a table
Instead of making a measure make one for each of the weekdays and place them on your table then use the same condittional formatting.
Monday = IF ( [Number of days] > 7; 1; IF ( WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > 2 || WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < 2; 0; 1 ) ) Tuesday = IF ( [Number of days] > 7; 1; IF ( WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > 3 || WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < 3; 0; 1 ) ) Wednesday = IF ( [Number of days] > 7; 1; IF ( WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > 4 || WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < 4; 0; 1 ) ) Thursday = IF ( [Number of days] > 7; 1; IF ( WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > 5 || WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < 5; 0; 1 ) ) Friday = IF ( [Number of days] > 7; 1; IF ( WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > 6 || WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < 6; 0; 1 ) )Check PBIX file attach with both options.
Regards,
MFelix
Hi Anonymous ,
Regarding your questions you can do the following:
More than 1 week
Create a measure:
Number of days = SUMX('Table';DATEDIFF('Table'[Schedule Start date];'Table'[Schedule End date];DAY)) + 1
Adjust your previous measure to:
Day of the week calculation =
IF (
[Number of days] > 7;
1;
IF (
WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > MAX ( 'Weekdays'[ID] )
|| WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < MAX ( 'Weekdays'[ID] );
0;
1
)
)
Assuming you want to have all days ocupied correct?
Making use of a table
Instead of making a measure make one for each of the weekdays and place them on your table then use the same condittional formatting.
Monday =
IF (
[Number of days] > 7;
1;
IF (
WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > 2
|| WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < 2;
0;
1
)
)
Tuesday =
IF (
[Number of days] > 7;
1;
IF (
WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > 3
|| WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < 3;
0;
1
)
)
Wednesday =
IF (
[Number of days] > 7;
1;
IF (
WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > 4
|| WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < 4;
0;
1
)
)
Thursday =
IF (
[Number of days] > 7;
1;
IF (
WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > 5
|| WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < 5;
0;
1
)
)
Friday =
IF (
[Number of days] > 7;
1;
IF (
WEEKDAY ( MAX ( 'Table'[Schedule Start Date] ); 1 ) > 6
|| WEEKDAY ( MAX ( 'Table'[Schedule End Date] ); 1 ) < 6;
0;
1
)
)
Check PBIX file attach with both options.
Regards,
MFelix