Search code examples
powerbipowerquerym

PowerBI Index by row combined with prevíous row


Hello I would need someones help please. I want to combine two different tasks and don't know how.

First I created an row number for each group: Description for Task1 I grouped the table by a station ID.

Now I want to get the value from the previous row: Description for Task2

The problem is that this doesn't work: Multiple Values Error I think this comes due to the fakt that the index is not unique. Because for example the index "1" exists for every ID.

Maybe it's easier to understand when u see the table. I blacked out specific values because they are not important for this. Table for Example

I would need to only take the index+1 where the index+1 and index have the same ID.

What I want to achive is to get a column which shows me the previous value from beschreibung. But only the previuos value where the ID is the same. Example

Does anyone know how to solve this? My guess is that you need to do the lookupvalue task in powerquery. But I don't know how. Maybe something like this? : Lookup Value

I welcome any help.


Solution

  • Based on your update:

    MeasurePrev = var __lastInd = CALCULATE(MAX('Table'[Beschreibung]), FILTER(ALL('Table'), 'Table'[index] = SELECTEDVALUE('Table'[index]) +1 ), VALUES('Table'[ID]))
    return  __lastInd 
    

    enter image description here

    CalculatedColumnPrev = var _idx = 'Table'[index] +1
    var _NodeId = 'Table'[ID]
    return
    CALCULATE(max('Table'[Beschreibung]), FILTER(ALL('Table'),  ('Table'[index]) = _idx && 'Table'[ID] = _NodeId) )
    

    enter image description here