Sep 02 2021 08:49 AM
I need help making this pivot:
Columns E:G lookup the bottom master lookup (K6:N9). I then thought I would make a second transfer lookup (top one in K1:R4) to fill in columns H:I based on =IFERRORVLOOKUP([@Name],Lookup_Transfer,5,0),[@Original Sector]), which works but then I needed it to be conditional of when it starts. I thought of a IF(AND where if the [@Month} from the Data table is is less than or equal to (I thought this was easiest but gladly take whatever allows my end result) End in column R and less than or equal to YEAR of column R to [@Year] in the Data table that way I get the correct values for columns H:I and then pivot to get the result I'm looking for. I get lost since how would I make it look to column R only for those who are in the transfer table.
Also, is there a way to display a pivotable with only values looking forward? In my example I want years 2021 and 2022 to show months 5-12 for 2021 and month 1 for 2022 but without showing month 1 in 2021.
Thank you for any help.
Sep 02 2021 01:27 PM
SolutionThat's better to restructure data a bit and do everything with data mode, but it takes some time plus entire logic is unclear.
As variant you may use formulas for
(New) Sector
=IFNA( LOOKUP( 2, 1/
([@Name] & [@Company] &[@[Original Sector]] = Lookup_1st[Name] & Lookup_1st[Company] & Lookup_1st[Original Sector] ) /
( ([@Year]*100+[@Month]) >= (YEAR(Lookup_1st[Start])*100 + MONTH(Lookup_1st[Start]) ) ) /
( ([@Year]*100+[@Month]) <= ( YEAR(Lookup_1st[End])*100 + MONTH(Lookup_1st[End]) ) ),
Lookup_1st[New Sector] ), "")
(New) Department
=IFNA( LOOKUP( 2, 1/
([@Name] & [@Company] &[@[Original Sector]] = Lookup_1st[Name] & Lookup_1st[Company] & Lookup_1st[Original Sector] ) /
( ([@Year]*100+[@Month]) >= (YEAR(Lookup_1st[Start])*100 + MONTH(Lookup_1st[Start]) ) ) /
( ([@Year]*100+[@Month]) <= ( YEAR(Lookup_1st[End])*100 + MONTH(Lookup_1st[End]) ) ),
Lookup_1st[New Department] ), "")
PivotTable doesn't show months without data, nothing special to do
Sep 03 2021 12:13 AM
Sep 03 2021 06:33 AM
@Jpalaci1 , you are welcome.
1) On the one hand such pattern with LOOKUP() exists for about 30 years, that's actually for what this function was designed. On the other hand that's my personal preferences, I prefer LOOKUP(), INDEX/MATCH and XLOOKUP(), never used VLOOKUP() and HLOOKUP(). But that's up to you which one to use.
2) Replying on post find this "Insert code" icon in editor bar
click on it, select Excel Formula and paste the formula
3) That's just formatting. Expand formula bar, with long formula insert new line by Alt+Enter, use spaces to separate part of formulas. Space and new lines are ignored during formula evaluation.
In formula bar such formula looks like
Alternatively without such formatting
or
=IFNA(LOOKUP(2,1/([@Name]&[@Company]&[@[Original Sector]]=Lookup_1st[Name]& Lookup_1st[Company]&Lookup_1st[Original Sector])/(([@Year]*100+[@Month])>= (YEAR(Lookup_1st[Start])*100+MONTH(Lookup_1st[Start])))/(([@Year]*100+[@Month])<=( YEAR(Lookup_1st[End])*100+MONTH(Lookup_1st[End]))),Lookup_1st[New Sector]),"")
Much harder to read and maintain.
4) Yes, that's division. 1/(divider)
Sep 02 2021 01:27 PM
SolutionThat's better to restructure data a bit and do everything with data mode, but it takes some time plus entire logic is unclear.
As variant you may use formulas for
(New) Sector
=IFNA( LOOKUP( 2, 1/
([@Name] & [@Company] &[@[Original Sector]] = Lookup_1st[Name] & Lookup_1st[Company] & Lookup_1st[Original Sector] ) /
( ([@Year]*100+[@Month]) >= (YEAR(Lookup_1st[Start])*100 + MONTH(Lookup_1st[Start]) ) ) /
( ([@Year]*100+[@Month]) <= ( YEAR(Lookup_1st[End])*100 + MONTH(Lookup_1st[End]) ) ),
Lookup_1st[New Sector] ), "")
(New) Department
=IFNA( LOOKUP( 2, 1/
([@Name] & [@Company] &[@[Original Sector]] = Lookup_1st[Name] & Lookup_1st[Company] & Lookup_1st[Original Sector] ) /
( ([@Year]*100+[@Month]) >= (YEAR(Lookup_1st[Start])*100 + MONTH(Lookup_1st[Start]) ) ) /
( ([@Year]*100+[@Month]) <= ( YEAR(Lookup_1st[End])*100 + MONTH(Lookup_1st[End]) ) ),
Lookup_1st[New Department] ), "")
PivotTable doesn't show months without data, nothing special to do