Forum Discussion

tito1986's avatar
tito1986
New Member
8 years ago
Solved

Previous rows power pivot

Hi, hello from Ecuador, i am a big problem.

 

I have the following payroll information and I need to get the previous row to get the percentage increase per item month by month but I can not find the solution.


Here's the example:
I have this information

 

Aditional, i have two measure for this data:
 
TOT_INGRESOS:=CALCULATE(SUM('Nomina'[valor]);Nomina[tipo rubro]="ingreso")
TOT_EGRESOS:=CALCULATE(SUM('Nomina'[valor]);Nomina[tipo rubro]="descuento")
 
When you insert a PivotTable i need the folowing:
Create a measure that returns the value of the previous row for each item.
 
 

I have many items of income and deduction, and there are months in which I have no values.
 
your help please.
  • tito1986,

     

    In DAX you can’t reference the previous row in any way because there is no order to the rows. In your scenairo, you need to get previous month's value, so you need to sort your data by date. And then get previous value by using LOOKUPVALUE function.

    PreviousValue = LOOKUPVALUE(Table1[Amount],Table1[Order],Table1[Order]-1)

     

    Regards,

    Charlie Liao

1 Reply

  • v-caliao-msft's avatar
    v-caliao-msft
    Microsoft Employee

    tito1986,

     

    In DAX you can’t reference the previous row in any way because there is no order to the rows. In your scenairo, you need to get previous month's value, so you need to sort your data by date. And then get previous value by using LOOKUPVALUE function.

    PreviousValue = LOOKUPVALUE(Table1[Amount],Table1[Order],Table1[Order]-1)

     

    Regards,

    Charlie Liao