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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
PC20
Frequent Visitor

Get the latest non-null value from a list of columns.

There are few columns in data. I want to get the latest non-null value from these columns. 

The NewOutputCol is my output column.

In first row, L1 column has the latest non-null value and therefore, output is "A".

In second row, L2 column has the latest non-null value and therefore, output is "E".

In thirs row, L3 column has the latest non-null value and therefore, output is "Z".


In real data, I have 10 such columns to scan from and over 90,000 rows.

 

Sample data:

L1L2L3NewOuputCol
AnullnullA
DEnullE
XnullZZ
1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @PC20 

 

In Power Query, you can create this custom column

List.Last(List.Select(Record.FieldValues(_), each _ <> null))




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
danextian
Super User
Super User

Hi @PC20 

 

In Power Query, you can create this custom column

List.Last(List.Select(Record.FieldValues(_), each _ <> null))




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Greg_Deckler
Community Champion
Community Champion

@PC20 Probably best if you unpivot your columns and add and index perhaps. Otherwise, maybe this:

Column = 
    VAR __Data = [L1] & "|" & [L2] & "|" & [L3]
    VAR __Table = 
        ADDCOLUMNS(
            GENERATESERIES(1,3,1),
            "__Data", PATHITEM(__Data,[Value],TEXT)
        )
    VAR __Max = MAXX(FILTER(__Table,[__Data] <> BLANK()),[Value])
    VAR __Result = MAXX(FILTER(__Table,[Value] = __Max),[__Data])
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

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