Forum Discussion

metcala's avatar
metcala
Helper III
3 years ago
Solved

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

  • 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]))

     

     

1 Reply

  • 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]))