Forum Discussion

jaml's avatar
jaml
Regular Visitor
6 years ago
Solved

Comparing stock periods

Hi guys, I would like your help with a private project of mine. I hope you have some ideas. This is probably very easy for some of you. Once a week I copy my entire portfolio and insert it in...
  • v-alq-msft's avatar
    6 years ago

    Hi, jaml 

     

    Based on your description, I created data to reproduce your scenario.

     

    You may create measures as follows.

     

    From period = 
    CALCULATE(
        MIN('Table'[Timestamp]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Stock Name] = MAX('Table'[Stock Name])
        )
    )
    To period = 
    CALCULATE(
        MAX('Table'[Timestamp]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Stock Name] = MAX('Table'[Stock Name])
        )
    )
    Amount = 
    var x = [To period]
    var y = [From period] 
    return
    CALCULATE(
        SUM('Table'[Amount of stocks]),
        'Table'[Timestamp] = x
    )-
    CALCULATE(
        SUM('Table'[Amount of stocks]),
        'Table'[Timestamp] = y
    )

     

     

    Result:

     

    Best Regards

    Allan

     

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