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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.