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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MM1984
Frequent Visitor

Last value in row

Hey, 

Is there a function to get the last value in a row?

Example PrimaryKey / Date1/ Date2/ Date3/ Date4 xx1 / 28.01.2020 / 01.01.2020

xx2 / 02.02.1922/ 10.08.2022/ 03.04.2011

 

DAX function last value for xx1 = 01.01.2020 For xx2 = 03.04.2011

 

Thanks a lot

 

marius

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @MM1984 ,

According to your description, here's my solution.

1.In Power Query, select all date columns at the same time, then click Unpivot Columns.

vkalyjmsft_0-1643878635075.png

Get the following table.

vkalyjmsft_1-1643878738145.png

2.Add an index column.

vkalyjmsft_2-1643878828841.png

3.Create a measure.

Last date= 
MAXX (
    FILTER (
        'Table',
        'Table'[Index]
            = MAXX (
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[PrimaryKey] = MAX ( 'Table'[PrimaryKey] )
                        && 'Table'[Value] <> BLANK ()
                ),
                'Table'[Index]
            )
    ),
    'Table'[Value]
)

4.Put PrimaryKey and the measure in a table visual, get the expected result.

vkalyjmsft_3-1643878957756.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

 

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

 

 

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @MM1984 ,

According to your description, here's my solution.

1.In Power Query, select all date columns at the same time, then click Unpivot Columns.

vkalyjmsft_0-1643878635075.png

Get the following table.

vkalyjmsft_1-1643878738145.png

2.Add an index column.

vkalyjmsft_2-1643878828841.png

3.Create a measure.

Last date= 
MAXX (
    FILTER (
        'Table',
        'Table'[Index]
            = MAXX (
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[PrimaryKey] = MAX ( 'Table'[PrimaryKey] )
                        && 'Table'[Value] <> BLANK ()
                ),
                'Table'[Index]
            )
    ),
    'Table'[Value]
)

4.Put PrimaryKey and the measure in a table visual, get the expected result.

vkalyjmsft_3-1643878957756.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

 

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

 

 

ValtteriN
Super User
Super User

Hi,

There isn't a direct function. In these kind of cases I would unpivot the data and use LASTNONBLANK while considering the key as a filter.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.