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
aramirez2
Helper I
Helper I

Primera y última compra del canal

Hola.

Estoy tratando de averiguar la primera y última compra del canal por CustomerID.

Mi tabla Sales tiene la siguiente estructura: Date - CustomerID - Channel - ProductID - Sales.

07/09/2020 2wa Web af22 8
07/09/2020 7j3 Web 22dd 2
06/09/2020 2wa Amazon 3dd 5
06/09/2020 7j3 Alliexpress ddd2 4
05/09/2020 2wa Alliexpress ss23 4

La tabla de ventas está vinculada a mi calendario, pero no puedo crear una medida que muestre el primer canal de compra y el último canal de compra en una tabla con todos mis CustomerIds.

¿Alguien puede ayudarme, por favor?

Gracias de antemano.

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

Hola @aramirez2 ,

Compruebe las medidas a continuación.

first = 
var mindate = CALCULATE(MIN('Table'[Date]),ALLEXCEPT('Table','Table'[CustomerID]))
return
CALCULATE(MAX('Table'[Channel]),FILTER(ALLEXCEPT('Table','Table'[CustomerID]),'Table'[Date]=mindate))

last = 
var last_date = CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[CustomerID]))
return
CALCULATE(MAX('Table'[Channel]),FILTER(ALLEXCEPT('Table','Table'[CustomerID]),'Table'[Date]=last_date))

El resultado se mostraría como se muestra a continuación.

1.PNG

Saludos

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

5 REPLIES 5
v-jayw-msft
Community Support
Community Support

Hola @aramirez2 ,

Compruebe las medidas a continuación.

first = 
var mindate = CALCULATE(MIN('Table'[Date]),ALLEXCEPT('Table','Table'[CustomerID]))
return
CALCULATE(MAX('Table'[Channel]),FILTER(ALLEXCEPT('Table','Table'[CustomerID]),'Table'[Date]=mindate))

last = 
var last_date = CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[CustomerID]))
return
CALCULATE(MAX('Table'[Channel]),FILTER(ALLEXCEPT('Table','Table'[CustomerID]),'Table'[Date]=last_date))

El resultado se mostraría como se muestra a continuación.

1.PNG

Saludos

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@aramirez2 , Probar como

firstnonblankvalue(Date, sum(Table[sales]))

Lastnonblankvalue(Date, sum(Table[sales]))

Funcionarán para el contexto de fila. Con el cliente visual, darán a nivel de cliente, con el producto del Cliente, darán a nivel de producto del cliente

Inténtelo, nivel de cliente forzado

calculate(firstnonblankvalue(Date, sum(Table[sales])), allexcept(Table, Table[Customer]))

calculate(lasttnonblankvalue(Date, sum(Table[sales])), allexcept(Table, Table[Customer]))

Tahreem24
Super User
Super User

@aramirez2 ,

Pruebe esto debajo de DAX para el primer y último canal.

Primer canal: CALCULATE(MAX(TAble[Channel]),FILTER(ALL(DateTable),DateTable[Date]-MIN(TDateTable[Date]))
Last Channel á CALCULATE(MAX(TAble[Channel]),FILTER(ALL(DateTable),DateTable[Date]-MAX(TDateTable[Date]))
Capture.PNG
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Gracias @Tahreem24 por su respuesta, pero su fórmula de medida no da ningún resultado:

channel.PNG

Mi tabe de Ventas es "pedidos" y mi Calendario es "Calendario_pedido". ¿Las fórmulas de medida funcionan si la tabla contenía solo las fórmulas CustomerId y First y Last Purchase?

He creado una columna de cálculo para eso.

Como pueden ver he adjuntado la captura de pantalla con todas las columnas requeridas y está funcionando bien.

Una cosa a enfocar es asegurarse de que tiene una relación adecuada entre el calendario y la tabla de pedidos.

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

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.