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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
lauraespinade
Regular Visitor

Restar fechas entre filas agregando columna

Buenas,

 

Soy nueva en Power Bi y no se si es posible restar fechas entre filas de una misma columna sin hacer uso de una medida.

¿ Es posible hacerlo con alguna funcion directamente sobre la tabla de datos?

lauraespinade_0-1649236829504.png

En el caso de la imagen, agregar una columna que en la segunda fila me de el valor de 0:00:51, en la tercera fila de 0:00:50

2 ACCEPTED SOLUTIONS
Vijay_A_Verma
Super User
Super User

Since you have just started, I will not give the complex way but the easiest way. Which is through Index. To see the working, refer below -

Open a blank Query - Advanced Editor - Remove everything from there - Paste the below code - OK

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIw0TUw0jUyMDJSMDCzMjKwMjBTitWJVnLCJmdqDpZzwZQztDKByPliyhlbGViC5fywyZkaKcXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Fechahora = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Category", type text}, {"Fechahora", type datetime}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Diff", each try [Fechahora]-#"Changed Type"[Fechahora]{[Index]-1} otherwise null)
in
    #"Added Custom"

 

View solution in original post

My last doubt is if it is possible in this way to calculate the difference but filtering by an ID.

In this table I have a column with different Ids, so I want to calculate the differences between hours for each ID.

View solution in original post

4 REPLIES 4
ArgenSuarez
New Member

Buenas Tardes, alguien me podra ayudar para ver la solución de restar fechas de distintos eventos, es decir el tiempo que esta detenida una tarea.

ArgenSuarez_0-1684865404912.png

Seria el valor fecha en Amarillo menos el valor en rojo.

Saludos y muchas gracias.

Los Leo

Vijay_A_Verma
Super User
Super User

Since you have just started, I will not give the complex way but the easiest way. Which is through Index. To see the working, refer below -

Open a blank Query - Advanced Editor - Remove everything from there - Paste the below code - OK

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIw0TUw0jUyMDJSMDCzMjKwMjBTitWJVnLCJmdqDpZzwZQztDKByPliyhlbGViC5fywyZkaKcXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Fechahora = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Category", type text}, {"Fechahora", type datetime}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Diff", each try [Fechahora]-#"Changed Type"[Fechahora]{[Index]-1} otherwise null)
in
    #"Added Custom"

 

My last doubt is if it is possible in this way to calculate the difference but filtering by an ID.

In this table I have a column with different Ids, so I want to calculate the differences between hours for each ID.

Thank you !!!

It works well 🙂 So useful to know it

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors