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
jitpbi
Post Patron
Post Patron

Extraer horas

Hola

Estoy recibiendo la columna de desviación de tiempo de la fuente de datos del tipo de texto que tiene valores como:

0 días 01:10:00

0 días 00:20:30

1 días 02:10:00

Necesito calcular horas a partir de estas columnas, por favor ayude a lograr esto.

Nota: No puedo convertir esta columna de texto en fecha/hora o duración.

Gracias

4 REPLIES 4
FrankAT
Community Champion
Community Champion

Hola @jitpbi ,

crear una nueva columna (véase la figura [1]).

Time = RIGHT('Table'[Deviation],8)

Utilice la siguiente medida y seleccione el tipo de datos (consulte la figura [2]).

Sum of Deviation = SUM('Table'[Time])

09-08-_2020_23-00-40.png

Saludos FrankAT

mahoneypat
Employee
Employee

Agregue una columna personalizada en el editor de consultas con esta fórmula. Le dará el total de horas, incluyendo horas parciales / decimales.

• Number.From(Text.BeforeDelimiter([Column1], " "))*24 + Duration.TotalHours(Duration.FromText(Text.AfterDelimiter([Column1], " ", 1)))

Si esto funciona para usted, márquelo como la solución. Los elogios también son apreciados. Por favor, avísame si no.

saludos

palmadita





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Greg_Deckler
Super User
Super User

@jitpbi - Podría crear una nueva columna que tomó el valor de su columna anterior y luego simplemente reemplazar " días " con ":" y luego podría ser capaz de convertir eso a la duración.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Fowmy
Super User
Super User

@jitpbi

Creo que necesitas calcular el total de horas de cada línea.

Fowmy_0-1596966163897.png


Pegue el código debajo en una consulta en blanco en el editor de avances y siga los pasos.




let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUorViVYyUEhJrCxWMDCwMjKwMjYAi4EJQ6iEkZWhgZUBUCIWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"0 days 01:10:00" = _t]),
    #"Demoted Headers" = Table.DemoteHeaders(Source),
    #"Filtered Rows" = Table.SelectRows(#"Demoted Headers", each ([Column1] <> "")),
    #"Trimmed Text" = Table.TransformColumns(#"Filtered Rows",{{"Column1", Text.Trim, type text}}),
    #"Inserted Text Before Delimiter" = Table.AddColumn(#"Trimmed Text", "Days", each Text.BeforeDelimiter([Column1], " "), type text),
    #"Inserted Text Between Delimiters" = Table.AddColumn(#"Inserted Text Before Delimiter", "Text Between Delimiters", each Text.BetweenDelimiters([Column1], "days", ":"), type text),
    #"Changed Type" = Table.TransformColumnTypes(#"Inserted Text Between Delimiters",{{"Days", Int64.Type}, {"Text Between Delimiters", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Text Between Delimiters", "Hours"}}),
    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Total Hours", each [Days] * 24 + [Hours])
in
    #"Added Custom"

________________________

¿He respondido a tu pregunta? Marque este post como una solución, esto ayudará a otros!.

Haga clic en el icono Thumbs-Up a la derecha si le gusta esta respuesta 🙂

YoutubeLinkedin

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.