Combining XLOOKUP and IF/S or SWITCH

PaulyK

Board Regular
Joined
Aug 27, 2015
Messages
50
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
I am trying (but so far failing) to use an Xlookup inside my IF (or SWITCH) formula.

The scenario: Currently the IF looks for a Cell ref and gives the result based on data in that row. However I want to be able to to look just for the corresponding data in a specified Cell (which will be a Project ID) and return a result related to that. I have two tables that the data is taken from (a Master and an Overview) but if I sort or filter the rows in Overview, the formula displays different results to what it should.

Therefore in Columns D, E, F on Master I wanted to 'lock' the formula to the ID in Column A on Overview and match it to Column A on Master.

Overview

Project Status Summary v0.2 - test2.xlsm
ABCDEFGHIJ
2Project #Project NameProject TypeOverall RAGUpdateApproved BudgetActual SpendDifferenceStart DateCompletion Date
3220000Project ATier 2GreenYes£ 150.00£ 500.00-£ 350.0006/06/2229/07/22
4220001Project BTier 3No RAG (Tier 3)No£ 4,500.00£ 2,000.00£ 2,500.0001/02/2223/07/22
5220002Project CTier 1AmberNo£ 75,000.00£ 68,000.00£ 7,000.0001/01/2228/07/22
6220003Project DTier 2AmberNo£ 3,000.00£ 1,500.00£ 1,500.0001/02/2229/12/22
7220004Project ETier 1AmberYes£ 138,000.00£ 115,000.00£ 23,000.0001/03/2220/07/22
8220005Project FTier 1AmberNo£ 72,000.00£ 68,500.00£ 3,500.0001/04/2213/01/23
9220006Project GTier 2AmberNot on Tracker£ 1,000.00£ 2,200.00-£ 1,200.0001/05/2204/07/22
10220007Project HTier 2AmberNot on Tracker£ 7,500.00£ 9,000.00-£ 1,500.0001/06/2202/09/22
11220008Project ITier 2GreenYes£ 4,000.00£ 3,400.00£ 600.0005/05/2202/11/22
12220009Project JTier 2RedNo£ 18,600.00£ 20,000.00-£ 1,400.0003/01/2230/06/22
13220010Project KTier 3No RAG (Tier 3)Not on Tracker£ 32,000.00£ -£ 32,000.0023/09/2210/02/23
Project Overview
Cell Formulas
RangeFormula
D3:D13D3=XLOOKUP([@[Project '#]],Master!$A$2:$A$12,TblRAGScore[Check])
H3:H13H3=IFERROR([@[Approved Budget]]-[@[Actual Spend]]," ")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D3:D13Expression=$D3="No RAG (Tier 3)"textNO
D3:D13Expression=$D3="Green"textNO
D3:D13Expression=$D3="Red"textNO
D3:D13Expression=$D3="Amber"textNO
E3:E13Expression=$E3="Not on Tracker"textNO
E3:E13Expression=$E3="No"textNO
E3:E13Expression=$E3="Yes"textNO
G3:G6Expression=ISBLANKtextNO
G3:G6Expression=$G3>$F3textNO
G3:G6Expression=$G3<=$F3textNO
B3:B13Cell ValueduplicatestextNO
H3:H13Cell Value<-1000textNO
B7:B13Cell ValueduplicatestextNO
J3:J13Expression=AND($J3>TODAY(), $J3-TODAY()<=30)textNO
J3:J13Expression=$J3<TODAY()textNO
J3:J13Expression=$J3=TODAY()+30textNO


Master
Project Status Summary v0.2 - test2.xlsm
ABCDEFGHJKLM
1IDProjectTierTrackerBudgetDateScoreRAGCheck2ScoreCriteriaRAG
2220000Project ATier 21113GreenGreen3All 3 Criteria MatchedGreen
3220001Project BTier 32125No RAG (Tier 3)Amber4Total 4 PointsAmber
4220002Project CTier 12114AmberAmber5Total 5 PointsAmber
5220003Project DTier 22114AmberAmber6No Criteria MatchedRed
6220004Project ETier 11124AmberAmberExceptionTIER 3 ProjectNo RAG (Tier 3)
7220005Project FTier 12114AmberAmber
8220006Project GTier 21225AmberAmber
9220007Project HTier 21214AmberAmber
10220008Project ITier 21113GreenGreen
11220009Project JTier 22226RedRed
12220010Project KTier 31113No RAG (Tier 3)Green
Master
Cell Formulas
RangeFormula
A2:A12A2=UNIQUE(TblSummary[Project '#])
B2:B12B2=XLOOKUP(A2,TblSummary[Project '#],TblSummary[Project Name])
C2:C12C2=XLOOKUP(A2,TblSummary[Project '#],TblSummary[Project Type])
D2:D12D2=SWITCH('Project Overview'!E3,"Yes", "1", "Not on Tracker","1","No","2")
E2:E12E2=IF('Project Overview'!H3<-1000,"2","1")
F2:F12F2=IF('Project Overview'!J3<=TODAY(),"2","1")
G2:G12G2=D2+E2+F2
H2:H12H2=IF([@Tier]="Tier 3","No RAG (Tier 3)",SWITCH(IFNA(XLOOKUP(A2,$A$2:$A$12,[Score]),""),$K$2,$M$2,$K$3,$M$3,$K$4,$M$4,$K$5,$M$5,""))
J2:J12J2=SWITCH([@Score],$K$2,$M$2,$K$3,$M$3,$K$4,$M$4,$K$5,$M$5,$K$6,$M$6)
Dynamic array formulas.
Named Ranges
NameRefers ToCells
rngBudgetsc=TblRAGScore[Budget]G2
rngDatescr=TblRAGScore[Date]G2
rngRAGSc=TblRAGScore[Score]H2:H12, J2
rngRATSc=TblRAGScore[Tracker]G2
rngTotalscr=TblRAGScore[Score]H2:H12, J2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M2:M6Expression=$M2="No RAG (Tier 3)"textNO
M2:M6Expression=$M2="Red"textNO
M2:M6Expression=$M2="Amber"textNO
M2:M6Expression=$M2="Green"textNO
H2:H12Expression=$H2="No RAG (Tier 3)"textNO
H2:H12Expression=$H2=$M$3textNO
H2:H12Expression=$H2=$M$5textNO
H2:H12Expression=$H2=$M$2textNO
G2:G12Expression=$G2=3textNO
G2:G12Expression=$G2=4textNO
G2:G12Expression=$G2=5textNO
G2:G12Expression=$G2=6textNO
Cells with Data Validation
CellAllowCriteria
M2:M6List=rngRAG
K2:K5List=rngRAGCnt
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Instead of -

Excel Formula:
=SWITCH('Project Overview'!E3,"Yes", "1", "Not on Tracker","1","No","2")

Try This in cell D3 of Master -

Excel Formula:
=Let(LUU,XLOOKUP($A2,'Project Overview'!A:A,'Project Overview'!E:E),IFS(LUU="Yes","1",LUU="Not on Tracker","1",LUU="No","2",True,"")
 
Upvote 0

Forum statistics

Threads
1,214,405
Messages
6,119,323
Members
448,887
Latest member
AirOliver

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