Forum Discussion
Time visualizaiton (occupancy vs. availability)
- 1 year ago
Dear IvanS ,
-- Create a table with 15-minute intervals
TimeIntervals = ADDCOLUMNS( GENERATE( CALENDAR(DATE(2025,1,1), DATE(2025,12,31)), SELECTCOLUMNS( GENERATESERIES(TIME(0,0,0), TIME(23,45,0), TIME(0,15,0)), "Time", [Value] ) ), "DateTime", [Date] + [Time] )-- Create a measure to check if charging session is active during each 15-minute interval
ChargingStatus = VAR CurrentInterval = SELECTEDVALUE('TimeIntervals'[DateTime]) RETURN IF( CALCULATE( COUNTROWS('ChargingData'), FILTER( 'ChargingData', 'ChargingData'[Charging from] <= CurrentInterval && 'ChargingData'[Charging to] > CurrentInterval ) ) > 0, "X", -- or use a color indicator like "Red" BLANK() -- or use a color indicator like "Green" )-- Use a Matrix visual with Location ID as rows, Time Intervals as columns, and ChargingStatus as values.
-- Alternatively, create a Gantt-like visual using a custom visual from the Power BI marketplace, linking the ChargingStart and ChargingEnd times to the Gantt chart start and end dates.Please mark this as solution if it helps you. Appreciate Kudos.
Dear IvanS ,
-- Create a table with 15-minute intervals
TimeIntervals =
ADDCOLUMNS(
GENERATE(
CALENDAR(DATE(2025,1,1), DATE(2025,12,31)),
SELECTCOLUMNS(
GENERATESERIES(TIME(0,0,0), TIME(23,45,0), TIME(0,15,0)),
"Time", [Value]
)
),
"DateTime", [Date] + [Time]
)
-- Create a measure to check if charging session is active during each 15-minute interval
ChargingStatus =
VAR CurrentInterval = SELECTEDVALUE('TimeIntervals'[DateTime])
RETURN
IF(
CALCULATE(
COUNTROWS('ChargingData'),
FILTER(
'ChargingData',
'ChargingData'[Charging from] <= CurrentInterval && 'ChargingData'[Charging to] > CurrentInterval
)
) > 0,
"X", -- or use a color indicator like "Red"
BLANK() -- or use a color indicator like "Green"
)
-- Use a Matrix visual with Location ID as rows, Time Intervals as columns, and ChargingStatus as values.
-- Alternatively, create a Gantt-like visual using a custom visual from the Power BI marketplace, linking the ChargingStart and ChargingEnd times to the Gantt chart start and end dates.
Please mark this as solution if it helps you. Appreciate Kudos.
Thank you FarhanJeelani , it is working but the function has performance issues with large dataset.