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
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
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