Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Syndicate_Admin
Administrator
Administrator

Nueva columna para crear bandas de tiempo

hola

Necesito crear una nueva columna que ponga una hora en un intervalo de tiempo

Los intervalos de tiempo están en franjas horarias

00:00-01:00
01:00-02:00
02:00-03:00
03:00-04:00
04:00-05:00
05:00-06:00

Mi conjunto de datos de ejemplo tiene este aspecto

Hora
00:02:10
09:45:56
06:33:53
00:00:20

00:01:42

El resultado esperado con la nueva columna tendría este aspecto:

HoraIntervalo de tiempo
00:02:1000:00-01:00
09:45:5609:00-10:00
06:33:5306:00-07:00
00:00:2000:00-01:00
00:01:4200:00-01:00

Cualquier ayuda sería muy apreciada

Gracias de antemano

2 ACCEPTED SOLUTIONS
Syndicate_Admin
Administrator
Administrator

No @KG1

Puede crear una columna con el siguiente código:-

Time_Bracket =
VAR start_hour =
    FORMAT ( Time_Bucket[Time], "hh" )
VAR end_hour =
    IF ( LEN ( start_hour + 1 ) = 1, "0" & start_hour + 1, start_hour + 1 )
RETURN
    start_hour & ":00 - " & end_hour & ":00"

Samarth_18_0-1627894341064.png

gracias

Samarth

View solution in original post

Había algunas filas en blanco al final del conjunto de datos: las he eliminado y ha funcionado perfectamente

Muchas gracias por su ayuda

View solution in original post

5 REPLIES 5
Syndicate_Admin
Administrator
Administrator

No @KG1

Puede crear una columna con el siguiente código:-

Time_Bracket =
VAR start_hour =
    FORMAT ( Time_Bucket[Time], "hh" )
VAR end_hour =
    IF ( LEN ( start_hour + 1 ) = 1, "0" & start_hour + 1, start_hour + 1 )
RETURN
    start_hour & ":00 - " & end_hour & ":00"

Samarth_18_0-1627894341064.png

gracias

Samarth

Gracias por responder, pero recibo el siguiente error

No se puede convertir el valor '' de tipo Text al tipo Number.

¿Podría por favor hágamelo saber el tipo de datos de su columna de tiempo?

Había algunas filas en blanco al final del conjunto de datos: las he eliminado y ha funcionado perfectamente

Muchas gracias por su ayuda

Si desea mantener esas filas de espacios en blanco, puede consultar el siguiente código:-

Time_Bracket =
VAR start_hour =
    FORMAT ( Time_Bucket[Time], "hh" )
VAR end_hour =
    IF ( LEN ( start_hour + 1 ) = 1, "0" & start_hour + 1, start_hour + 1 )
VAR result = start_hour & ":00 - " & end_hour & ":00"
RETURN
    IF ( NOT ( ISBLANK ( Time_Bucket[Time] ) ), result, BLANK () )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.