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
SErgey-kuznetso
Frequent Visitor

Calcular el número de días entre la última y la venta anterior DAX

¿Qué fórmula/medida se puede utilizar para calcular el número de días entre la última y la última pero una venta? Existe la siguiente tabla y es necesario calcular, por ejemplo, el número de días entre las ventas de la empresa1 el 10/21/2020 (último) y el 12/31/19 (penúltimo).

SErgey-kuznetso_0-1603269388987.png

O simplemente puede sugerir cómo encontrar la penúltima venta de la empresa. Calcula el número de días entre que puedo yo mismo.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@SErgey-kuznetso , como nuevas columnas

Max Date á maxx(filter(Table, [company] á earlier([company])),[Date])
segundo last: maxx(filter(Table, [company] á earlier([company]) && [Date] < earlier([max Date]) ),[Date])
diff á datediff([segundo último],[max Date],day)

o como medidas

Max Date á maxx(filter(allselected(Table), [company] á max([company])),[Fecha])
segundo last: maxx(filter(allselected(Table), [company] á max([company]) && [Date] < max([max Date]) ),[Fecha])
diff á datediff([segundo último],[max Date],day)

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@SErgey-kuznetso , como nuevas columnas

Max Date á maxx(filter(Table, [company] á earlier([company])),[Date])
segundo last: maxx(filter(Table, [company] á earlier([company]) && [Date] < earlier([max Date]) ),[Date])
diff á datediff([segundo último],[max Date],day)

o como medidas

Max Date á maxx(filter(allselected(Table), [company] á max([company])),[Fecha])
segundo last: maxx(filter(allselected(Table), [company] á max([company]) && [Date] < max([max Date]) ),[Fecha])
diff á datediff([segundo último],[max Date],day)

Tahreem24
Super User
Super User

@SErgey-kuznetso ,

Prueba esta Medida. También estoy conectando la captura de pantalla con la salida:

Día de la casa de la habitación
VAR Min_ - CALCULATE(MIN(Tbl2[Date]),ALLEXCEPT(Tbl2,Tbl2[Category]))
VAR Max_ - CALCULATE(MAX(Tbl2[Date]),ALLEXCEPT(Tbl2,Tbl2[Category]))
RETURN DATEDIFF(Min_,Max_,DAY)
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
manikumar34
Solution Sage
Solution Sage

@SErgey-kuznetso ,

No está claro, usa algo como esto.

DATEDIFF(DATE(2020,10,21),DATE(2019,12,31),DAY)

saludos

Manikumar





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




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.