- Inicio
- Recursos
- Galería HTML
- Seguimiento de entregas
Seguimiento de entregas
¿Cuántos días tarda en llegar un pedido?
Grabación en Power BI Desktop sobre el modelo Contoso-Retail, año 2024.
Los pedidos enviados como una ruta de reparto: una parada por cada día después del pedido, con la parte que llega ese día y cuántos han llegado ya. Desde el plazo prometido la ruta se vuelve roja, y un camión marca el día en que ha llegado la mitad.
¿Te aviso cuando salga un visual nuevo?
Opcional: la descarga no lo necesita. Un correo cada dos semanas como mucho. Y si quieres todos los visuales de pago, está el Pase Deneb.
Qué necesita
- Una columna con los días de entrega de cada pedido
- Una marca de entrega tarde
Cómo lo conecto a mis datos
- Copia la medida «HTML Delivery Tracker» del archivo .dax.
- Cambia la columna de días de entrega y la marca de entrega tarde por las de tu modelo.
- Ponla en un visual HTML Content y filtra un año y el canal de envíos en la página.
La medida completa
Es la misma que el archivo .dax de la carpeta. Cópiala con el botón.
-- The HTML: put this measure in an HTML Content visual. Uses FactSales[Delivery Days] and FactSales[Late Delivery] of Contoso-Retail.
-- By CSalcedoDataBI · https://csalcedodatabi.com/recursos/html-content-power-bi/seguimiento-entregas · MIT
'HTML Delivery Tracker' =
VAR _days =
FILTER (
ADDCOLUMNS ( VALUES ( 'FactSales'[Delivery Days] ), "@n", CALCULATE ( COUNTROWS ( 'FactSales' ) ) ),
'FactSales'[Delivery Days] > 0 && [@n] > 0
)
VAR _total = SUMX ( _days, [@n] )
VAR _late = CALCULATE ( MIN ( 'FactSales'[Delivery Days] ), 'FactSales'[Late Delivery] = "Yes" )
VAR _maxd = MAXX ( _days, 'FactSales'[Delivery Days] )
VAR _step = DIVIDE ( 880, MAX ( _maxd - 1, 1 ) )
VAR _c =
ADDCOLUMNS (
_days,
"@s", DIVIDE ( [@n], _total ),
"@cum", VAR _d = 'FactSales'[Delivery Days] RETURN DIVIDE ( SUMX ( FILTER ( _days, 'FactSales'[Delivery Days] <= _d ), [@n] ), _total ),
"@x", ROUND ( 60 + ( 'FactSales'[Delivery Days] - 1 ) * _step, 0 )
)
VAR _maxs = MAXX ( _c, [@s] )
VAR _med = MINX ( FILTER ( _c, ROUND ( [@cum], 2 ) >= 0.5 ), 'FactSales'[Delivery Days] )
VAR _p95 = MINX ( FILTER ( _c, ROUND ( [@cum], 2 ) >= 0.95 ), 'FactSales'[Delivery Days] )
VAR _lateShare = DIVIDE ( SUMX ( FILTER ( _c, 'FactSales'[Delivery Days] >= _late ), [@n] ), _total )
VAR _xl = ROUND ( 60 + ( _late - 1.5 ) * _step, 0 )
VAR _xm = ROUND ( 60 + ( _med - 1 ) * _step, 0 )
RETURN
"<div style=""font-family:'Segoe UI',sans-serif;color:#334155;width:100%;height:100%;display:flex;flex-direction:column;box-sizing:border-box;padding:4px""> "
& "<div style=""font-size:16px;font-weight:700;color:#1F3A5F;margin:0 0 2px 2px"">Delivery tracker · how many days a shipped order takes</div> "
& "<div style=""font-size:12px;color:#64748B;margin:0 0 6px 2px"">Half the orders arrive by day " & _med & " and 95% by day " & _p95 & " · " & FORMAT ( _lateShare, "0.0%", "en-US" ) & " arrive late (" & _late & " days or more) · " & FORMAT ( _total, "#,0", "en-US" ) & " shipped orders</div> "
& "<svg viewBox=""0 0 1000 470"" preserveAspectRatio=""xMidYMid meet"" style=""flex:1;width:100%""> "
& "<rect x=""" & _xl & """ y=""20"" width=""" & 990 - _xl & """ height=""400"" rx=""10"" fill=""#FDECEC""/> "
& "<text x=""" & _xl + 12 & """ y=""44"" font-size=""14"" font-weight=""700"" fill=""#B42318"">LATE · " & _late & "+ DAYS</text> "
& "<text x=""40"" y=""44"" font-size=""14"" font-weight=""700"" fill=""#1E7A45"">ON TIME</text> "
& "<line x1=""30"" y1=""330"" x2=""" & _xl & """ y2=""330"" stroke=""#94A3B8"" stroke-width=""18"" stroke-linecap=""round""/> "
& "<line x1=""" & _xl & """ y1=""330"" x2=""985"" y2=""330"" stroke=""#E8A29B"" stroke-width=""18"" stroke-linecap=""round""/> "
& "<line x1=""30"" y1=""330"" x2=""985"" y2=""330"" stroke=""#FFFFFF"" stroke-width=""2"" stroke-dasharray=""12 10""/> "
& CONCATENATEX (
_c,
"<rect x=""" & [@x] - 22 & """ y=""" & ROUND ( 300 - DIVIDE ( [@s], _maxs ) * 220, 0 ) & """ width=""44"" height=""" & ROUND ( DIVIDE ( [@s], _maxs ) * 220, 0 ) & """ rx=""5"" fill=""" & IF ( 'FactSales'[Delivery Days] >= _late, "#B42318", "#2D6A9F" ) & """ fill-opacity=""0.85""><title>Day " & 'FactSales'[Delivery Days] & ": " & FORMAT ( [@n], "#,0", "en-US" ) & " orders (" & FORMAT ( [@s], "0.0%", "en-US" ) & ") · " & FORMAT ( [@cum], "0.0%", "en-US" ) & " delivered by then</title></rect> "
& "<text x=""" & [@x] & """ y=""" & ROUND ( 292 - DIVIDE ( [@s], _maxs ) * 220, 0 ) & """ text-anchor=""middle"" font-size=""13"" font-weight=""600"" fill=""#334155"">" & IF ( [@s] >= 0.0095, FORMAT ( [@s], "0%", "en-US" ), "" ) & "</text> "
& "<circle cx=""" & [@x] & """ cy=""330"" r=""13"" fill=""#FFFFFF"" stroke=""" & IF ( 'FactSales'[Delivery Days] >= _late, "#B42318", "#1F3A5F" ) & """ stroke-width=""4""/> "
& "<text x=""" & [@x] & """ y=""335"" text-anchor=""middle"" font-size=""12"" font-weight=""700"" fill=""#1F3A5F"">" & 'FactSales'[Delivery Days] & "</text> "
& "<text x=""" & [@x] & """ y=""372"" text-anchor=""middle"" font-size=""13"" font-weight=""700"" fill=""" & IF ( 'FactSales'[Delivery Days] >= _late, "#B42318", "#1F3A5F" ) & """>" & FORMAT ( [@cum], "0%", "en-US" ) & "</text>",
"",
'FactSales'[Delivery Days], ASC
) & " "
& "<text x=""30"" y=""458"" font-size=""12"" fill=""#64748B"">Circle = days after the order · bar = share that arrives that day · number below = delivered so far</text> "
& "<g transform=""translate(" & _xm - 26 & ",384)""><rect x=""0"" y=""6"" width=""34"" height=""22"" rx=""3"" fill=""#E4572E""/><path d=""M34 12 h10 l8 9 v7 h-18 z"" fill=""#E4572E""/><circle cx=""10"" cy=""30"" r=""5"" fill=""#1E293B""/><circle cx=""42"" cy=""30"" r=""5"" fill=""#1E293B""/></g> "
& "<text x=""" & _xm + 32 & """ y=""410"" font-size=""12"" font-weight=""700"" fill=""#E4572E"">half delivered by day " & _med & "</text> "
& "</svg> "
& "</div>"
El informe lee los datos de muestra por internet: al abrirlo la primera vez, pulsa Actualizar. El visual responde a los filtros de la página. Licencia MIT.