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

Calcular devoluciones diarias

Tengo datos en el siguiente formato

FechaPrecio
15-12-20 100
14-12-20 50
13-12-20 20
12-12-2010

Me gustaría crear una medida que pueda calcular las devoluciones diarias con la siguiente fórmula

FechaPrecioDevuelve
15-12-20 100(100-50)/50
14-12-20 50(50-20)/20
13-12-20 20(20-10)/10
12-12-20100

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Sachy123 , Pruebe una nueva columna como

nueva columna ?
var _max á maxx(table,[Date] < earlier([Date])),[Date])
devolución
[Precio] - maxx(filter(table, [Fecha] á _max),[Precio])


O

nueva columna ?
var _max á maxx(table,[Date] < earlier([Date])),[Date])
var _1 á maxx(table, [Fecha] - _max),[Precio])
devolución
divide([Price] - _1,_1)

View solution in original post

5 REPLIES 5
Sachy123
Helper V
Helper V

finalmente este funciona como un encanto

nueva columna ?
var _max á maxx(table,[Date] < earlier([Date])),[Date])
var _1 á maxx(table, [Fecha] - _max),[Precio])
devolución
divide([Price] - _1,_1)

v-yangliu-msft
Community Support
Community Support

No @Sachy123,

Lo siento, esta es mi negligencia. Debe ser crear una columna calculada, no crear una medida. Cometí un error arriba

Saludos

Liu Yang

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

Sachy123
Helper V
Helper V

Hola chicos, obtengo un subrayado rojo cuando uso la función EARLIER y no hay autosuggestions.

amitchandak
Super User
Super User

@Sachy123 , Pruebe una nueva columna como

nueva columna ?
var _max á maxx(table,[Date] < earlier([Date])),[Date])
devolución
[Precio] - maxx(filter(table, [Fecha] á _max),[Precio])


O

nueva columna ?
var _max á maxx(table,[Date] < earlier([Date])),[Date])
var _1 á maxx(table, [Fecha] - _max),[Precio])
devolución
divide([Price] - _1,_1)

v-yangliu-msft
Community Support
Community Support

No @Sachy123,

Estos son los pasos que puede seguir:

1. Cree una columna calculada.

Return =
var _datamax=CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),'Table'[Date]<EARLIER('Table'[Date])))
var _price2=CALCULATE(MAX('Table'[Price]),FILTER('Table',[Date]=_datamax))
var _price1=CALCULATE(MAX('Table'[Price]))
var _final_price=(_price1-_price2)/_price2
return IF(_price2=0,BLANK(),_final_price)

2. Resultado

v-yangliu-msft_0-1608082912458.png

Puede descargar el archivo PBIX desde aquí.

Saludos

Liu Yang

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

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