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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jcawley
Helper III
Helper III

¿Fecha máxima antes de un rango filtrado?

Hola

Estoy tratando de ver cuántos clientes han venido durante el último mes (o cualquier rango filtrado realmente) que tienen una cita completa, que han comprado algo previamente de nosotros, y que no han estado en nuestra oficina en los últimos 365 días (en relación con cualquier rango de fechas filtrada).

Tengo dos mesas. Una tabla (1) muestra todos los clientes que han comprado un artículo y otra tabla (2) que muestra todas las fechas en las que un cliente ha venido a la tienda.

Tabla 1

Id
12345
23456

Tabla 2

IdTipoFechaCompletado
12345Chequeo06/01/2014
12345Chequeo06/28/2020
23456Chequeo06/01/2014
23457Chequeo06/01/2020No


Cualquier ayuda sería muy apreciado!

5 REPLIES 5
dax
Community Support
Community Support

Hola @jcawley

Si es posible, ¿podría informarme información más detallada (como su salida esperada y sus datos de muestra)? Entonces te ayudaré más correctamente.

Por favor, enmascarar los datos confidenciales antes de cargar.

Gracias por su comprensión y apoyo.
Saludos
Zoe Zhi

Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

amitchandak
Super User
Super User

@jcawley, para el mes anterior puede utilizar la inteligencia de tiempo

Ejemplo

last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))

Puedes durar 360 días como

Rolling 360 day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX(Sales[Sales Date]),-360,Day))  

Para obtener lo mejor de la función de inteligencia del tiempo. Asegúrese de que tiene un calendario de fechas y que se ha marcado como la fecha en la vista de modelo. Además, únase a ella con la columna de fecha de su/s hecho/s. Consulte:
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Vea si mi seminario web sobre Time Intelligence puede ayudar: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Apreciamos tus Felicitaciones.

AllisonKennedy
Super User
Super User

Podrías abordar esto de varias maneras. Una opción es extraer la información que necesita en la Tabla2 como COLUMNAS calculadas:

Fecha de la visita anterior: MAXX(FILTER(Table2,Table2[ID]-EARLIER(Table2[ID]) &&Table2[Date]<EARLIER(Table2[Date])),Table2[Date])
Comprado: IF(COUNTROWS(RELATEDTABLE(Table1))>0,"Yes","No")
A continuación, cree un MEASURE para determinar si son su cliente clave o no:
KeyClient ? IF(DATEDIFF(SELECTEDVALUE(Table2[Previous Visit Date]),MIN(DimDate[Date]),DAY)>365&&SELECTEDVALUE(Table2[Completed])"Yes" && SELECTEDVALUE(Table2[Purchased])"Yes","Yes", "No")

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hola Allison,

¡Gracias por la ayuda! ¿Hay alguna manera de que pueda contar esta medida? Creo que esta puede ser la solución, pero cuando lo pongo en cualquier formato visual en el informe, sólo obtengo un "No" en lugar de un conteo.

Intente reordenarlo para usar COUNTROWS y un FILTER:

KeyClientCount ? COUNTROWS(FILTER(Table2, DATEDIFF(Table2[Previous Visit Date],MIN(DimDate[Date]),DAY)>365&&Table2[Completed]-"Yes" && Table2[Purchased]-"Yes"))

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors