Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Previous value from one calculated column

Hi!

I want to create column in power query. It is count of previous value from new column / Rate . In first cell we need to strart with 1 as previous value and then continue with privious values. 

Is there some way to create this column in power query .

Def= if [Index]=1 then 1/[Rate] else List.Range(Source[Def],[Index]-1,1)/[Rate]

 

 

Thank you !

  • Anonymous's avatar
    Anonymous
    3 years ago

    AlienSx  Thanks for your solutions maybe I am doing someting wrong but there is still Expression.Error: A circular reference was encountered during evaluation. But  this works for me :

    = List.Transform(List.Skip(List.Accumulate(#"Zmenený typ1"[Rate], {1}, (s,c)=> s & {List.Last(s)/c})), Number.From)

     

    but thanks i appreciate it

9 Replies

  • Hello, Anonymous List.Range returns you a list, not a single value. Providing that your index column starts with 1, try this instead

    Def = if [Index]= 1 then 1/[Rate] else Source[Def]{[Index] - 2}/[Rate]

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    AlienSx Hello, there is still Error becaouse of Def column which I am creating . Is tehre some way to sole it ? 

     

    • AlienSx's avatar
      AlienSx
      Super User

      what kind of error? Select a cell with error and get back with PQ error message

  • Anonymous's avatar
    Anonymous
    Not applicable

    AlienSx Only first cell is Ok others are with  Error 

    Translation :

    Expression.Error: Def table column not found.
    Details:
    Def

    • AlienSx's avatar
      AlienSx
      Super User

      Formula can't find [Def] column in Source table. You either don't have a table named Source or colum named Def in there. Do you still have Zdroj table? Use it instead of Source in the code. 

      • Anonymous's avatar
        Anonymous
        Not applicable

        AlienSx Translation of Source is Zdroj in my language . I thaought that is ok to put there only "Source".  I repleace Source with name of table and there is anothr error 

        Expression.Error: A circular reference was encountered during evaluation.