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
amaniramahi
Helper V
Helper V

Función anterior

Hola

Tengo la siguiente tabla

ProductoFechaQtyResultados del año anterior
Aaa1/1/20175
Bbb1/1/20173
Ccc1/1/20173
Aaa1/3/20178
Bbb1/3/20174
Ccc1/3/20176
Ccc1/9/20177
Aaa1/1/20186
Ccc1/1/20187
Bbb1/3/20187
Ccc1/9/20188
Aaa1/1/20199
Bbb1/3/20196
Ccc1/9/20197

en la columna "Resultados del año anterior", quería calcular la cantidad vendida para el mismo día del año anterior Y para el mismo producto

Cuando escribo la siguiente fórmula, filtra las fechas

CACLCULATE(SUM(TABLE[QTY]),FILTER(TABLE,DATEADD(TABLE[DATE].[Date],1,YEAR)=EARLIER(TABLE[DATE].[Date])))

funciona y suma la cantidad vendida en la misma fecha del año anterior (independientemente del producto)

pero cuando agredo otro filtro con el valor anterior en Tipo de producto me da en blanco.

Necesito ayuda

2 ACCEPTED SOLUTIONS
az38
Community Champion
Community Champion

@amaniramahi

¿cómo se filtra exactamente por producto? mostrar por favor frase equivocada completa.

en el caso más común puede parecer

CACLCULATE(SUM(TABLE[QTY]),
FILTER(TABLE, 
DATEADD(TABLE[DATE].[Date],1,YEAR)=EARLIER(TABLE[DATE].[Date])
&&
TABLE[Product] = EARLIER(TABLE[Product])
)
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

amitchandak
Super User
Super User

@amaniramahi , Pruebe una nueva columna como

sumx(filter(Table,Table[Product] ?earlier(Table[Product]) && year(Table[Date]) ? year(earlier(Table[Date]))-1),TABLE[QTY])

Medida

ejemplo con tabla de fechas

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

blog de referencia -https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

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.

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@amaniramahi , Pruebe una nueva columna como

sumx(filter(Table,Table[Product] ?earlier(Table[Product]) && year(Table[Date]) ? year(earlier(Table[Date]))-1),TABLE[QTY])

Medida

ejemplo con tabla de fechas

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

blog de referencia -https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

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.

@amitchandak por qué debería filtrar solo por YEAR? hay muchas fechas dentro del mismo año 😞

Gracias a ambos, trabajé para ambas soluciones

az38
Community Champion
Community Champion

@amaniramahi

¿cómo se filtra exactamente por producto? mostrar por favor frase equivocada completa.

en el caso más común puede parecer

CACLCULATE(SUM(TABLE[QTY]),
FILTER(TABLE, 
DATEADD(TABLE[DATE].[Date],1,YEAR)=EARLIER(TABLE[DATE].[Date])
&&
TABLE[Product] = EARLIER(TABLE[Product])
)
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hola @az38, probé su fórmula, me da en blanco para todas las columnas 😞

az38
Community Champion
Community Champion

@amaniramahi

tal vez usted necesita para borrar todo su contexto con la función ALL(), como

CALCULATE(SUM(TABLE[QTY]),
FILTER(ALL(TABLE), 
DATEADD(TABLE[DATE].[Date],1,YEAR)=EARLIER(TABLE[DATE].[Date])
&&
TABLE[Product] = EARLIER(TABLE[Product])
)
)

de lo contrario, tiene que comprobar sus datos o proporcionarnos un ejemplo de datos


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

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.