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
IlseV
Frequent Visitor

Crear columna con el cálculo de la diferencia de 2 celdas que están en diferentes columnas y filas

Hola

En Excel esto es muy fácil, pero me gustaría saber si esto es posible en power bi.

Tengo una visión general de las actuaciones con el inicio y el fin de la hora:

example.png

cada fila es 1 registro con inicio y fin: comenzar 13:48:37 y terminar 14:21:20

Es fácil calcular la diferencia por fila, por lo que el througputtime: por ejemplo, primera línea: 14:21:20 menos 13:48:37 es 00:32:43

Pero lo que no puedo resolver es: calcular el "tiempo perdido" hasta el siguiente registro:

Quiero decir: la diferencia entre la hora de inicio del registro 2 y la hora de finalización del registro 1:

14:23:20 menos 14:21:20 es 00:03:00

Y ese cálculo para cada registro hasta que no haya más datos.

Espero que alguien pueda ayudarme.

Muchas gracias de antemano

Ilse

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hola @IlseV ,

En primer lugar, cree una columna de índice;

A continuación, cree 2 columnas como se muestra a continuación:

Difference = 'Table'[End]-'Table'[Begin ]
lost time = 
var _nexbegin=CALCULATE(MAX('Table'[Begin ]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])+1))
Return
IF(_nexbegin=BLANK(),BLANK(),_nexbegin-'Table'[End])

Y verás:

Annotation 2020-09-14 105957.png

Para el archivo .pbix relacionado, pls ver adjunto.

Saludos
Kelly
¿He respondido a tu pregunta? ¡Marca mi puesto como una solución!

View solution in original post

4 REPLIES 4
v-kelly-msft
Community Support
Community Support

Hola @IlseV ,

En primer lugar, cree una columna de índice;

A continuación, cree 2 columnas como se muestra a continuación:

Difference = 'Table'[End]-'Table'[Begin ]
lost time = 
var _nexbegin=CALCULATE(MAX('Table'[Begin ]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])+1))
Return
IF(_nexbegin=BLANK(),BLANK(),_nexbegin-'Table'[End])

Y verás:

Annotation 2020-09-14 105957.png

Para el archivo .pbix relacionado, pls ver adjunto.

Saludos
Kelly
¿He respondido a tu pregunta? ¡Marca mi puesto como una solución!
amitchandak
Super User
Super User

@IlseV , Pruebe una nueva columna como

diff con la última fila [marea inicial en proceso] - maxx(table,[beginning tide in process] < earlier([beginning tide in process])),([End tide in process]))

Hi, thank you very much for your help!

I would never have found this.

 

One more question:

the first row can't calculate a difference because there is no row zero, so it returns the begin time 13:48:37

Is it possible to return this value (of the first row) blank?

Otherwise I get in trouble when I want to calculate sums or averages?

 

Many thanks,

Ilse

@IlseV - Prueba lo siguiente:

diff with last row = 
  VAR __Current = [begin tij in process]
  VAR __Previous = MAXX(FILTER(Table,[begin tij in process] < EARLIER([begin tij in process])),[End tij in process])
RETURN
  IF(ISBLANK(__Previous) || YEAR(__Previous)<1900 || __Previous<0,BLANK(),[Current]-__Previous)


@ 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...

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.