Forum Discussion
Build Availability Table
- 1 year ago
Hi stribor45 ,
Certainly. You can add a 30 minutes bucket field in the time table:
TimeTable = ADDCOLUMNS( GENERATESERIES(0, 1439, 1), "Time", TIME(INT([Value] / 60), MOD([Value], 60), 0), "Hour", INT([Value] / 60), "Minute", MOD([Value], 60), "Hour-Minute", FORMAT(TIME(INT([Value] / 60), MOD([Value], 60), 0), "hh:mm"), "30-Minute Bucket", FORMAT( TIME(INT([Value] / 60), IF(MOD([Value], 60) < 30, 0, 30), 0), "hh:mm" ) )Then write a measure like below:
Participants during Duration 30Min = VAR SelectedTime = MAX('TimeTable'[Time]) // Assume Time is in "HH:MM" format VAR BucketStart = TIME(HOUR(SelectedTime), IF(MINUTE(SelectedTime) < 30, 0, 30), 0) VAR BucketEnd = IF(MINUTE(SelectedTime) < 30, BucketStart + TIME(0, 30, 0), BucketStart + TIME(1, 0, 0)) // Concatenate participants within the time window VAR ParticipantsList = CONCATENATEX( FILTER( DISTINCT('Table'), 'Table'[Start Time] <= BucketEnd && 'Table'[End Time] >= BucketStart ), RIGHT('Table'[Participant], 1), ", " ) // Return either the list of participants or '〇' if no participants RETURN IF( ISBLANK(ParticipantsList), "-", // Display "-" when no participants ParticipantsList )You can use the measure above alongside a color measure in conditional formatting to achieve a visualization shown at the bottom.
Color = IF ([Participants during Duration 30Min]="-","#90EE90","#FF0000") //the color can be replaced with hexadecimal codes like #6B2328)))I have attached an example pbix file for your reference.
Best regards,
Hi stribor45 ,
Certainly. You can add a 30 minutes bucket field in the time table:
TimeTable =
ADDCOLUMNS(
GENERATESERIES(0, 1439, 1),
"Time", TIME(INT([Value] / 60), MOD([Value], 60), 0),
"Hour", INT([Value] / 60),
"Minute", MOD([Value], 60),
"Hour-Minute", FORMAT(TIME(INT([Value] / 60), MOD([Value], 60), 0), "hh:mm"),
"30-Minute Bucket",
FORMAT(
TIME(INT([Value] / 60),
IF(MOD([Value], 60) < 30, 0, 30), 0),
"hh:mm"
)
)
Then write a measure like below:
Participants during Duration 30Min =
VAR SelectedTime = MAX('TimeTable'[Time]) // Assume Time is in "HH:MM" format
VAR BucketStart = TIME(HOUR(SelectedTime), IF(MINUTE(SelectedTime) < 30, 0, 30), 0)
VAR BucketEnd = IF(MINUTE(SelectedTime) < 30,
BucketStart + TIME(0, 30, 0),
BucketStart + TIME(1, 0, 0))
// Concatenate participants within the time window
VAR ParticipantsList =
CONCATENATEX(
FILTER(
DISTINCT('Table'),
'Table'[Start Time] <= BucketEnd &&
'Table'[End Time] >= BucketStart
),
RIGHT('Table'[Participant], 1),
", "
)
// Return either the list of participants or '〇' if no participants
RETURN
IF(
ISBLANK(ParticipantsList),
"-", // Display "-" when no participants
ParticipantsList
)
You can use the measure above alongside a color measure in conditional formatting to achieve a visualization shown at the bottom.
Color =
IF ([Participants during Duration 30Min]="-","#90EE90","#FF0000")
//the color can be replaced with hexadecimal codes like #6B2328)))
I have attached an example pbix file for your reference.
Best regards,
DataNinja777 would it be possible to adjust this based on additional activity that is attached to training columns? Say for example "driving" training also have "First Aid" activity that is attached to it and may be scheduled always on Wednesdays from 11-12 so every time you counting we leave everything as is only this time we add 1 to Wedesday under column 11