admin管理员组

文章数量:1289836

Within PowerBI, I have a table with many stock tickers with weights, across many dates. I'm trying to calculate a day over day change but can't seem to create a calculated column and/or structure the data in way that let's me do so. The target is the column on the very right (the day over day difference) but I'm fine with calculating the PreviousDay column in an effort to obtain the difference more easily.

Ticker Date Weight PreviousDay Difference from PreviousDay
AAPL 2/11/2025 9.72% 10.50% -0.78%
CSX 2/11/2025 5.32% 4.00% 1.32%
JNJ 2/11/2025 1.88% 2.00% -0.12%
NKE 2/11/2025 2.42% 4.00% -1.58%
AAPL 2/10/2025 10.50% 12.00% -1.50%
CSX 2/10/2025 4.00% 6.00% -2.00%
JNJ 2/10/2025 2.00% 5.00% -3.00%
NKE 2/10/2025 4.00% 6.00% -2.00%
AAPL 2/7/2025 12.00%
CSX 2/7/2025 6.00%
JNJ 2/7/2025 5.00%
NKE 2/7/2025 6.00%

Within PowerBI, I have a table with many stock tickers with weights, across many dates. I'm trying to calculate a day over day change but can't seem to create a calculated column and/or structure the data in way that let's me do so. The target is the column on the very right (the day over day difference) but I'm fine with calculating the PreviousDay column in an effort to obtain the difference more easily.

Ticker Date Weight PreviousDay Difference from PreviousDay
AAPL 2/11/2025 9.72% 10.50% -0.78%
CSX 2/11/2025 5.32% 4.00% 1.32%
JNJ 2/11/2025 1.88% 2.00% -0.12%
NKE 2/11/2025 2.42% 4.00% -1.58%
AAPL 2/10/2025 10.50% 12.00% -1.50%
CSX 2/10/2025 4.00% 6.00% -2.00%
JNJ 2/10/2025 2.00% 5.00% -3.00%
NKE 2/10/2025 4.00% 6.00% -2.00%
AAPL 2/7/2025 12.00%
CSX 2/7/2025 6.00%
JNJ 2/7/2025 5.00%
NKE 2/7/2025 6.00%

Hoping my example makes sense but if not please let me know. Appreciate any help. Thanks.

Share Improve this question asked Feb 20 at 0:50 bigjdawg43bigjdawg43 1831 gold badge1 silver badge10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

you can try this

PreviousDay2 =
VAR _last =
    MAXX (
        FILTER (
            'Table',
            'Table'[Ticker] = EARLIER ( 'Table'[Ticker] )
                && 'Table'[Date] < EARLIER ( 'Table'[Date] )
        ),
        'Table'[Date]
    )
RETURN
    IF (
        ISBLANK ( _last ),
        BLANK (),
        MAXX (
            FILTER (
                'Table',
                'Table'[Ticker] = EARLIER ( 'Table'[Ticker] )
                    && 'Table'[Date] = _last
            ),
            'Table'[Weight]
        )
    )


difference =
IF (
    ISBLANK ( 'Table'[PreviousDay2] ),
    BLANK (),
    'Table'[Weight] - 'Table'[PreviousDay2]
)

本文标签: PowerBI Day over Day changeStack Overflow