cancel
Showing results for 
Search instead for 
Did you mean: 
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-kalyj-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-kalyj-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
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th!

Power BI Dev Camp Session 22 without aka link and time 768x460.jpg

Check it Out!

Watch Session 22 Ted's Dev Camp along with past sessions!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!