Find rows relative to current row's value in excel (DAX)

后端 未结 3 931
不思量自难忘°
不思量自难忘° 2021-01-22 08:51

Is there a way to filter rows based on your current row\'s value using DAX (I\'m using power pivot) ?

In other words, If I had a table \"progress\" with \'ID\' that is i

3条回答
  •  孤城傲影
    2021-01-22 09:12

    JShmay,

    the solution could be much simpler if you use combination of SUMX function and EARLIER.

    Simply add a new calculated column with this formula:

    =SUMX (
        FILTER ( Progress, EARLIER ( [ID] ) = [ID] + 1 ),
        Progress[PERCENTAGE]
    )
    

    EARLIER returns the current row, so if you compare it with the previous one, it can then return the correct value. This approach might not be very intuitive, but it's much more efficient and could save you lot of time.

    The output should then look like this:

    enter image description here

    Try playing around to achieve the desired result, but I believe this is the simplest and most efficient approach (as far as processing time goes).

    Hope this helps.

    UPDATE: Read this article about using EARLIER in DAX queries. It might be helpful.

提交回复
热议问题