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
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
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.