Forum Discussion

habibcss's avatar
habibcss
Regular Visitor
9 years ago
Solved

manipulating cells in power bi

Hi, I wonder if we can manipulate cells of one colomn, to create other column. For example, in this test, I want to put the first cell equal 0 then subtract the cell i-1 and the cell i    ...
  • v-ljerr-msft's avatar
    9 years ago

    Hi habibcss,

     

    If I understand you correctly, you should be able to follow steps below to get your expected result.:smileyhappy:

     

    I assume you have a table called "Table1" like below.

     

     

    1. Add an Index Column for your table within Query Editor under Add Column tab.

     

     

    2. Then you should be able to use the formula below to create a new calculate column in the table to get your expected result.

    Column = 
    VAR currentIndex = Table1[Index]
    VAR currentValue = Table1[Value]
    RETURN
        IF (
            currentIndex = 0,
            0,
            currentValue
                - CALCULATE (
                    MAX ( Table1[Value] ),
                    FILTER ( ALL ( Table1 ), Table1[Index] = currentIndex - 1 )
                )
        )
    

     

    Regards