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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors