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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Mengeltje
Frequent Visitor

How to get last values of column

Hi all,
I have a question. I have a datasource which consists of a few columns followed by multiple status columns, each consisting of a combination of 3. What I need is the last status combination of columns. That can sometimes be the first status, sometimes the 4th or 5th.

 

What I have:

Mengeltje_0-1695018968174.png

What I need:

Mengeltje_1-1695019012611.png

 

The example above is as clarifying. I hope someone can help me.

Thanks in advance!

2 REPLIES 2
Ahmedx
Super User
Super User

Ahmedx
Super User
Super User

pls try is

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUAyIjAyNjJR2lgKL89KLU4mIg09BUz8AIJu7o5AwkXfLzUoGUkQGSjLu7F5BER7E6EINNYcqgWg2N9AzMYGLOwSlYtGKYYQ5TH1ySWFQCpIGWIwR9XV3R3G2AJOsSHIwma4QhC3OaBZqpsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"Status 1" = _t, #"Date 1" = _t, #"Person 1" = _t, #"Status 2" = _t, #"Date 2" = _t, #"Person 2" = _t, #"Status 3" = _t, #"Date 3" = _t, #"Person 3" = _t, #"Status 4" = _t, #"Date 4" = _t, #"Person 4" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Status 1", type text}, {"Date 1", type date}, {"Person 1", type text}, {"Status 2", type text}, {"Date 2", type date}, {"Person 2", type text}, {"Status 3", type text}, {"Date 3", type date}, {"Person 3", type text}, {"Status 4", type text}, {"Date 4", type date}, {"Person 4", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,Table.ColumnNames(#"Changed Type")),
    #"Added Custom" = Table.AddColumn(#"Replaced Value", "LastStatus", each List.LastN(
List.Select(
Record.FieldValues(_),each _<> null),3){0}),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Lastdate", each List.LastN(
List.Select(
Record.FieldValues(_),each _<> null),4){1}),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Lastpersone", each List.LastN(
List.Select(
Record.FieldValues(_),each _<> null),5){2})
in
    #"Added Custom2"

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors