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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
vic24he
Frequent Visitor

Checking multiple rows for same ID, see if a value exists in a different column

Hi all,

 

I have a data set that I'm having trouble with. Data example:

 

ID  |  Year

1   |   null

1   |  2000

1   |  null

2   |  null

3   |  null

3   | 2001

 

I need to know if the Year column is populated for the ID, either it's there or it's not. I cannot filter out null values from Year because then the 2 ID would be removed as well. The ultimate goal is that I would be able to identify which IDs have no Year value. From this data set, 1 and 3 I would classify as having Year present, 2 is not present. Is there a way to do this in power query? 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

lbendlin_0-1731709551048.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUVKK1YEwjAwMDOAcMMMIxjBGZgDVGSrFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Year = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"Rows", each _, type table [ID=nullable text, Year=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Year Populated", each if List.Count(List.RemoveNulls([Rows][Year]))>0 then "yes" else "no")
in
    #"Added Custom"

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

I would copy the table, remove nulls from the year column, then remove duplicates from the table. Then just left outer join your original table to the new table on the ID column (the original table on the left).

 

--Nate

ThxAlot
Super User
Super User

Easy enough,

ThxAlot_0-1731754668226.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Hi - is there a power query solution? I am not using PBI with DAX, but rather dealing with a larger data set in excel using PQ. I looked at your response below and I'm not sure how power pivot is able to load the results into a data table

Hello,
I am interested in this thread and the 2 solutions work very well.
Regarding the Power Pivot proposal, is it possible to load the result into an Excel sheet without using a pivot table?
As for a query where the table can be updated
Thanks in advance

Best regardsFilter.jpg

YES and NO.

 

Yes for creating a refreshable pivot in a worksheet this way,

ThxAlot_0-1731777879593.png

 

No because inherently, a pivot always imposes "group by" operation on selected columns by default.

ThxAlot_1-1731778285677.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Thanks @ThxAlot  for your reply,
I had also tried using a pivot table.
Have a nice evening

lbendlin
Super User
Super User

lbendlin_0-1731709551048.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUVKK1YEwjAwMDOAcMMMIxjBGZgDVGSrFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Year = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"Rows", each _, type table [ID=nullable text, Year=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Year Populated", each if List.Count(List.RemoveNulls([Rows][Year]))>0 then "yes" else "no")
in
    #"Added Custom"

Thanks, this worked!

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