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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
metcala
Helper III
Helper III

Custom Formula Look Up Value For Matching Criteria

Hi

 

I am struggling a little bit to find a solution to correct some data. Here is the data structure:

 

PeriodEmployee IDPay BandCategoryCost
1/1123NULLA50
1/1123Band 2B100
1/1123NULLC12
2/1123NULLA60
2/1123Band 3B40
2/1123NULLC30

 

My current thinking is to add a Revised Pay Band column that looks up Period and Employee ID and if it finds a Pay Band value that is not null it populates the Revised Pay Band.

 

Here is the desired outcome but open to suggestions if there is a more optimal solution:

 

PeriodEmployee IDPay BandCategoryCostRevised Pay Band
1/1123NULLA50Band 2
1/1123Band 2B100Band 2
1/1123NULLC12Band 2
2/1123NULLA60Band 3
2/1123Band 3B40Band 3
2/1123NULLC30Band 3

 

I have tried it in DAX and couldn't get it working but think this is probably something that should be done in Power Query anyway.

 

Any help or pointers would be much appreciated!

 

Thanks

1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

The following code adds a column that returns the first [Pay Band] value that is not null for the value of [Period] and [Employee ID] for the row being evaluated.

Table.AddColumn(#"Previous Step", "revisedPayBand", (x) => List.First(Table.SelectRows(#"Previous Step", each [Period] = x[Period] and [Employee ID] = x[Employee ID] and [Pay Band] <> null)[Pay Band]))

 

jgeddes_0-1671655294694.png

 





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

Proud to be a Super User!





View solution in original post

1 REPLY 1
jgeddes
Super User
Super User

The following code adds a column that returns the first [Pay Band] value that is not null for the value of [Period] and [Employee ID] for the row being evaluated.

Table.AddColumn(#"Previous Step", "revisedPayBand", (x) => List.First(Table.SelectRows(#"Previous Step", each [Period] = x[Period] and [Employee ID] = x[Employee ID] and [Pay Band] <> null)[Pay Band]))

 

jgeddes_0-1671655294694.png

 





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

Proud to be a Super User!





Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.