Dynamically pulling allowances and ignoring certain allowance for each employee

hananak

Board Regular
Joined
Feb 10, 2022
Messages
110
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Dear All,

I have a file, in which the data tab fetches the data via Power Query in a table. There is second tab, in which we have to layout the data in a certain way to do some calculations for each employee based on the allowances they are getting. The complications are that certain allowances needs to be ignored when dynamically pulling the allowances and then use xlookup to pull the amounts from the data table based on allowances.

I have attached the picture, the first table reflects they way the data is there in the "Data tab" and the second table shows the way I want the result.

I hoping if this can be done either via Power query or Formulas, all I am trying to do is to avoid doing manual calculations.

Your help would be really appreciated.

Thanks.
 

Attachments

  • Result.jpg
    Result.jpg
    235.9 KB · Views: 38
The formula has an little issue, The R2:R4 and Q2:Q4 is the list of allowances to be excluded. For most of the employees, I have added the allowances to be excluded, then the formula works flawlessly but the moment there is an employee, who has no allowances that should be excluded and whatever the allowances they are getting is fine. The formula does not work because I did not put anything for this particular employee on the R2:R4 and Q2:Q4 - list of allowances, as there is nothing to exclude for them.

I would appreciate if you could fix it.

Thanks for your help!
Another thing - on R2:R4 and Q2:Q4 - list of allowances. If I put for an employee same allowance twice to exclude, then the formula does not exclude that allowance at all. If this can be fixed as well.

Thanks for your help.
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
The formula has an little issue, The R2:R4 and Q2:Q4 is the list of allowances to be excluded. For most of the employees, I have added the allowances to be excluded, then the formula works flawlessly but the moment there is an employee, who has no allowances that should be excluded and whatever the allowances they are getting is fine. The formula does not work because I did not put anything for this particular employee on the R2:R4 and Q2:Q4 - list of allowances, as there is nothing to exclude for them.

I would appreciate if you could fix it.

Thanks for your help!

Hopefully, e.g. wrapping the original formula into IFERROR could do the trick:

Excel Formula:
=IFERROR(FILTER(FILTER(B2:B19,(A2:A19=F22)),BYROW(--(FILTER(B2:B19,(A2:A19=F22))=TRANSPOSE(FILTER(R2:R4,Q2:Q4=F22))),LAMBDA(a,SUM(a)))<>1),FILTER(B2:B19,A2:A19=F22))
 
Upvote 0
Hopefully, e.g. wrapping the original formula into IFERROR could do the trick:

Excel Formula:
=IFERROR(FILTER(FILTER(B2:B19,(A2:A19=F22)),BYROW(--(FILTER(B2:B19,(A2:A19=F22))=TRANSPOSE(FILTER(R2:R4,Q2:Q4=F22))),LAMBDA(a,SUM(a)))<>1),FILTER(B2:B19,A2:A19=F22))
Thanks for your reply. There are still two problems.

1) If I do not put anything for an employee in the exclude allowance table, the formula works but when I add employees allowances in the exclude table. It picks the last allowance and show it twice in the final result.

2) If we populate an allowance for same employee twice in the exclude table, it does not exclude that allowance in the final result --> Duplications fails the formula to work.

Please help!
 
Upvote 0
The easiest way to address this would be to create a helper column next to "Amount" column with two values where 1 = the allowance is included, 0 = the allowance is excluded; then you could use a simple FILTER with two conditions, i.e. Employee No and Helper Column.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,181
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top