Pular para o conteúdo
GridBelt
  • Teste de Excel
  • Prática
  • Programas
  • Preços
Entrar
Começar o teste gratuito
  • Teste de Excel
  • Prática
  • Programas
  • Preços
EntrarCriar conta
Começar o teste gratuito
GridBelt

Pratique Excel no seu navegador.

Teste de Excel

  • Nível 1: Iniciante
  • Nível 2: Intermediário
  • Nível 3: Avançado
  • Teste de Excel em 7 dias
  • Ranking
  • Teste de Excel para entrevista
  • Avaliação de Excel da Indeed

Prática

  • Todos os exercícios
  • Programas
  • Para iniciantes

Guias

  • Fórmulas do Excel
  • Atalhos do Excel

Empresa

  • Sobre nós
  • Preços
  • Como corrigimos

© GridBelt. Todos os direitos reservados.

  • Política de Privacidade
  • Termos de Uso
  • Política de Reembolso

Excel é uma marca comercial da Microsoft Corporation. Indeed, TestGorilla, SHL e outras marcas pertencem aos seus respectivos proprietários. O GridBelt é um site de prática independente e não tem afiliação com Microsoft, TestGorilla, SHL ou Indeed, nem é endossado ou patrocinado por eles.

  1. Prática
  2. /
  3. XLOOKUP

XLOOKUP with two criteria: price by product and region

  • Avançado
  • ~10 min
  • XLOOKUP

Enunciado em inglês

A building-materials supplier prices by region: the Prices sheet holds 60 rows — 15 products × 4 regions — with product, region, unit and unit price. The Quotes sheet has 30 quote lines, each with a product in column C and a region in column D. A lookup on the product alone returns the first region's price and is wrong on 24 of the 30 lines; the key is the pair product + region.

O que você precisa fazer

  1. 1On Quotes, click F2 and build the two-part key: C2&D2 joins the product and the region into one text.
  2. 2Type =XLOOKUP(C2&D2, then build the matching key for the whole price list: Prices!$A$2:$A$61&Prices!$B$2:$B$61 (select each column on the Prices tab, press F4 / ⌘T, join them with &).
  3. 3Add the return column Prices!$D$2:$D$61, close the bracket and press Enter — Excel 365 evaluates the joined columns as an array, no Ctrl+Shift+Enter needed.
  4. 4Fill F2 down to F31. Alternative without arrays: =SUMIFS(Prices!$D$2:$D$61,Prices!$A$2:$A$61,C2,Prices!$B$2:$B$61,D2) works because every pair appears exactly once.

Células de resposta

Correção

Digite sua fórmula na grade, pressione Enter e depois clique em Verificar. Avaliamos o valor de cada célula de resposta e a fórmula por trás dele.

Tarefas

  1. Não verificadoIn F2, return the unit price from the Prices sheet for the product in C2 and the region in D2 — XLOOKUP on the two keys joined with & (or SUMIFS with both criteria) — then fill down to F31.

Recomendamos um computador para as tarefas de planilha. A planilha rola dentro desta caixa.

StartInsertFormulasDataView
A1fxPreparando sua pasta de trabalho…
A
B
C
D
E
F
G
H
I
J
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Sheet1

Digite sua fórmula na planilha e depois verifique.

Sobre este exercício

Um conjunto de dados de 90 linhas em 2 planilhas, uma célula de resposta, cerca de 10 minutos. Corrigido no seu navegador: o valor e a fórmula por trás dele, com feedback que mostra o que corrigir.

Como resolver

  • Quotes!F2=XLOOKUP(C2&D2,Prices!$A$2:$A$61&Prices!$B$2:$B$61,Prices!$D$2:$D$61)

C2&D2 glues the product and the region into one text, and Prices!A2:A61&Prices!B2:B61 does the same for every row of the price list at once, producing a temporary array of 60 combined keys. XLOOKUP then finds the combined key in that array and returns the price from the same row — a two-column match without a helper column. SUMIFS reaches the same number another way: it adds every price whose product and region match, and since each pair appears exactly once, the sum is that single price.

Pitfall 1: joined keys can collide — "AB"&"C" equals "A"&"BC"; insert a separator that never appears in the data (C2&"|"&D2 on both sides) when keys are free text. Pitfall 2: SUMIFS silently sums duplicates and returns 0 for a missing pair, where XLOOKUP returns #N/A; use SUMIFS only when uniqueness is guaranteed and 0 is not a plausible price. Pitfall 3: in Excel 2019 and earlier, the array form needs INDEX/MATCH entered with Ctrl+Shift+Enter: =INDEX(Prices!$D$2:$D$61,MATCH(C2&D2,Prices!$A$2:$A$61&Prices!$B$2:$B$61,0)). Alternatives: boolean algebra =XLOOKUP(1,(Prices!$A$2:$A$61=C2)*(Prices!$B$2:$B$61=D2),Prices!$D$2:$D$61) avoids concatenation; =SUMPRODUCT((Prices!$A$2:$A$61=C2)*(Prices!$B$2:$B$61=D2)*Prices!$D$2:$D$61) is the pre-SUMIFS form; FILTER(…) spills every match, useful when pairs are not unique. Performance: array concatenation evaluates the whole price list for every quote row — fine for thousands of rows, slow for hundreds of thousands, where a helper key column on the Prices sheet is the classic fix.

Outras formas que funcionam

  • =SUMIFS(Prices!$D$2:$D$61,Prices!$A$2:$A$61,C2,Prices!$B$2:$B$61,D2) — works in every Excel version; relies on each pair being unique
  • =XLOOKUP(1,(Prices!$A$2:$A$61=C2)*(Prices!$B$2:$B$61=D2),Prices!$D$2:$D$61) — boolean array instead of concatenation
  • =INDEX(Prices!$D$2:$D$61,MATCH(C2&D2,Prices!$A$2:$A$61&Prices!$B$2:$B$61,0)) — INDEX/MATCH array form (Ctrl+Shift+Enter before Excel 365)
  • =SUMPRODUCT((Prices!$A$2:$A$61=C2)*(Prices!$B$2:$B$61=D2)*Prices!$D$2:$D$61) — the classic two-criteria formula

Erros comuns

Looking up the product only, =XLOOKUP(C2,Prices!$A$2:$A$61,Prices!$D$2:$D$61): it returns the first region listed for that product (North), which is wrong for every quote line in another region — 24 of 30 here.

Como corrigimos

Qualquer fórmula que produza o resultado certo é aceita, a menos que a tarefa cite uma função: nesse caso, outra função vale metade da pontuação. Comparamos os valores com uma pequena tolerância e ignoramos maiúsculas e espaços no texto. Um número certo digitado à mão em vez de uma fórmula vale metade da pontuação. Tarefas com várias células valem a pontuação integral com 100% das células certas e metade a partir de 50%. Quando faz diferença, também mudamos uma célula de entrada em uma cópia da sua planilha e verificamos se sua fórmula acompanha.

Respostas calculadas com as regras do Excel 365 e verificadas no nosso corretor em 16 de novembro de 2026. Autor: GridBelt team.

Nestes programas

  • Excel test in 7 days, Plano do nível 3Dia 5
  • Excel for Data AnalystsDia 9
  • Excel for Accounting and BookkeepingDia 9

Exercícios relacionados

  • Replace VLOOKUP with XLOOKUPIntermediário, ~6 min
  • Look left: employee ID by emailAvançado, ~6 min
  • Two-way lookup in a matrixAvançado, ~8 min
  • Last order date per customerAvançado, ~10 min

Referência da função

Documentação oficial

Próximo exercício

INDEX and MATCH exact lookup