cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Carla17
New Member

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.

View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors