Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Carla17
Frequent Visitor

Get value from other row in table

Hi, 

 

I'm looking for a formula display the column "previous close" in this table.

My table is linked to a proper functioning date table. A formula with "PREVIOUS" is not working because of weekends. 

 

Carla17_1-1624032793894.png

 

Thnx for helping me out.

 

Carla

 

 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Carla17 

 

You can use the following two methods to add a new column.

 

Previous Close =
MAXX (
    TOPN (
        1,
        FILTER (
            'Table',
            'Table'[Ticker] = EARLIER ( 'Table'[Ticker] )
                && 'Table'[Date] < EARLIER ( 'Table'[Date] )
        ),
        'Table'[Date], DESC
    ),
    'Table'[Close]
)

 

Or 

 

Previous Close 2 = 
VAR _previousDate =
    MAXX (
        FILTER (
            ALL ( 'Date' ),
            'Date'[Work Day] = 1
                && 'Date'[Date] < EARLIER ( 'Table'[Date] )
        ),
        'Date'[Date]
    )
VAR _previousClose =
    MAXX (
        FILTER (
            'Table',
            'Table'[Ticker] = EARLIER ( 'Table'[Ticker] )
                && 'Table'[Date] = _previousDate
        ),
        'Table'[Close]
    )
RETURN
    _previousClose

 

With the second method, you need to have a [Work Day] column in Date table to mark if a date is a working day.

062101.jpg

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @Carla17 

 

You can use the following two methods to add a new column.

 

Previous Close =
MAXX (
    TOPN (
        1,
        FILTER (
            'Table',
            'Table'[Ticker] = EARLIER ( 'Table'[Ticker] )
                && 'Table'[Date] < EARLIER ( 'Table'[Date] )
        ),
        'Table'[Date], DESC
    ),
    'Table'[Close]
)

 

Or 

 

Previous Close 2 = 
VAR _previousDate =
    MAXX (
        FILTER (
            ALL ( 'Date' ),
            'Date'[Work Day] = 1
                && 'Date'[Date] < EARLIER ( 'Table'[Date] )
        ),
        'Date'[Date]
    )
VAR _previousClose =
    MAXX (
        FILTER (
            'Table',
            'Table'[Ticker] = EARLIER ( 'Table'[Ticker] )
                && 'Table'[Date] = _previousDate
        ),
        'Table'[Close]
    )
RETURN
    _previousClose

 

With the second method, you need to have a [Work Day] column in Date table to mark if a date is a working day.

062101.jpg

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors