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

Cómo comprobar el valor de fecha de una columna de fecha de tabla está entre los valores de 2 filas de otra tabla

Hi, I am struggling with the following issue in Power BI desktop. My requirement is, how to check the Date Time value in Table A is in between the Sighting Date time values in Table B, if it is in between then show the minimum date/time record from Table B along with Table A record. In the below example, the record value 3/5/2020 3:48:33 PM from Table A is in between the date time values which are in 2 rows (3/4/2020 4:33:00 PM and 3/6/2020 5:33:00 AM) in Table B. In this show the minimum date-time record from Table B along with Table A row. I am in need of your helpo how to achieve this in Power BI desktop. The expected results is shown below.
Thank you for your help.

Tabla A:

Número de cocheFecha-horaTipo de evento
ACTX0232933/5/2020 3:48:33 PMChoque

Tabla B:

Número de cocheFecha de avistamiento HoraIndicador
ACTX0232933/4/2020 4:33:00 PML
ACTX0232933/6/2020 5:34:00 AML
ACTX0232933/6/2020 7:44:15 AML

Resultado esperado:

Número de cocheFecha-horaTipo de eventoFecha de avistamiento HoraIndicador
ACTX0232933/5/2020 3:48:33 PMChoque3/4/202 4:33:00 PML
8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hola

Estas fórmulas de columna calculadas funcionan en la Tabla1

Sighting Date Time = CALCULATE(Max(Table2[Sighting Date Time]),FILTER(Table2,Table2[Car Number]=EARLIER(Table1[Car Number])&&Table2[Sighting Date Time]<=EARLIER(Table1[Date Time])))
=LOOKUPVALUE(Table2[Indicator],Table2[Car Number],Table1[Car Number],Table2[Sighting Date Time],Table1[Sighting Date Time])

Espero que esto ayude.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Ashish, Gracias por los cálculos. Los implementé y probé el informe ahora. Te dejaré que publiques las actualizaciones.

Una vez más, agradezca su ayuda.

Ashish, la solución que apoyaste funcionó. Muchas gracias por su ayuda.

Gracias

Sreedhar

De nada.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
V-pazhen-msft
Community Support
Community Support

@sreedhary

Intente crear las dos columnas siguientes en la tabla A.

Sighting Date Time 1 = CALCULATE(MAX('Table B'[Sighting Date Time]),FILTER('Table B',[Sighting Date Time]<'Table A'[DateTime]&&'Table B'[Car Number]='Table A'[Car Number]))

Indication 1 = CALCULATE(MAX('Table B'[Indication]),FILTER('Table B',[Sighting Date Time]<'Table A'[DateTime] &&'Table B'[Car Number]='Table A'[Car Number]))

Equipo de Apoyo Comunitario Paul Zheng _
Si este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Paul, Gracias por las fórmulas. Los implementé y probé el informe. Le haré saber si hay algún problema.

Una vez más, agradezca su ayuda.

amitchandak
Super User
Super User

@sreedhary , Nueva columna en la Tabla 1

Nueva columna: minx(filter(Table2,Table1[Car Number] ?Table2[Car Number] && Table1[Date Time] >Table2[Date Time] ),Tabl22[Date Time])

Amit, Gracias por la respuesta. Pero estoy recibiendo un error cuando uso la expresión sugerida.

"Query(5,5) Un único valor para una columna 'Número de coche' en la tabla Tabla A no se puede detemined..."

Además, necesito comprobar que el valor de la columna de fecha de la tabla A está entre los valores de columna De fecha de la tabla B (nota: estas filas abarcadas 2).

Espero que esté claro. Por favor, avísame.

Pleasae aconsejar.

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.

Top Solution Authors