Forum Discussion

JACK__'s avatar
JACK__
Frequent Visitor
2 years ago
Solved

Create a Column in Matrix which does (this week price) - (last week price) for multiple weeks

So no idea where to start with this soltuion. What matrix I am after: Week 1 1 2 2 3 3 4 4 Item Price Change Price  Change Price Change Price Change 123456_ 5   5 ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi JACK__ ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) This is my test data. 

    (2) We can create a calculated column.

    Change = 
    IF (
        [Week]
            = CALCULATE (
                MIN ( 'Table'[Week] ),
                FILTER ( ALL ( 'Table' ), 'Table'[Item] = EARLIER ( 'Table'[Item] ) )
            ),
        BLANK (),
        [Price]
            - CALCULATE (
                SUM ( 'Table'[Price] ),
                FILTER (
                    'Table',
                    'Table'[Item] = EARLIER ( 'Table'[Item] )
                        && 'Table'[Week]
                            = EARLIER ( 'Table'[Week] ) - 1
                )
            )
    )

    (3) Then the result is as follows.

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly.