cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Super User IV
Super User IV

@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)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

3 REPLIES 3
Super User IV
Super User IV

@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)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

Super User II
Super User II

@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 : HR Analytics Report , Hotel Management Report, and Sales Analysis Report
Super User I
Super User I

@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
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Wave Release 2

Check out the updates in Power BI.

Overview of Power BI 2020 release wave 2!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.