Forum Discussion
MEDIA MOVIL
Buenos días soy nueva aquí, y en Power Bi, necesitaría ayuda con una formula que no entiendo lo que me esta pasando.
Tengo que calcular la media móvil acumulada de ingresos por empleado.
Para ello he calculado el total ingresos mes TotalIngresos = sum(INGRESOS[SALDO])
He calculado los ingresos por empleado: IngrEmple = [TotalIngresos]/[Nº Trabajadores a Fecha]
He calculado el acumulado ingresos por empleado: AcumunladoIngresosporEmpleado = CALCULATE([IngrEmple], DATESINPERIOD('DIM_FECHA ALTABAJA'[Fecha],MAX('DIM_FECHA ALTABAJA'[Fecha]),-12, MONTH))
Y me arroja este resultado:
Me voy a Excel a comprobarlo y veo que el resultado no es el mismo.
Muchisimas gracias por ayudarme.
Un saludo
3 Replies
- amitchandakSuper User
MAMENZAL , For cumulative try like
CALCULATE([IngrEmple], filter(allselected('DIM_FECHA ALTABAJA') ,'DIM_FECHA ALTABAJA'[Date] = MAX('DIM_FECHA ALTABAJA'[Date])))
- Syndicate_AdminAdministrator
Thank you very much, but the truth is that it does not work either.
- AnonymousNot applicable
Hi MAMENZAL ,
You can create a table to extract date value and use it as the category of your visual.
Then you can write a measure formula to extract the current date value as a condition to looping table records and get cumulative results.measure = var _select=MAX('Date'[Date]) return AVERAGEX( FILTER( SUMMARIZE(ALL('Table'), 'Table'[Date],'Table'[Staff], "Avg value",AVERAGE('Table'[amount])), 'Table'[Date] >=DATE(YEAR(_select)-1,MONTH(_select),DAY(_select))&& 'Table'[Date]<=_select&&'Table'[Staff]=MAX('Table'[Staff])), [Avg value])Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.