Saltar al contenido
GridBelt
  • Prueba de Excel
  • Práctica
  • Programas
  • Precios
Iniciar sesión
Empezar la prueba gratuita
  • Prueba de Excel
  • Práctica
  • Programas
  • Precios
Iniciar sesiónCrear cuenta
Empezar la prueba gratuita
GridBelt

Practica Excel en tu navegador.

Prueba de Excel

  • Nivel 1: Principiante
  • Nivel 2: Intermedio
  • Nivel 3: Experto
  • Prueba de Excel en 7 días
  • Clasificación
  • Prueba de Excel para entrevistas
  • Evaluación de Excel de Indeed

Práctica

  • Todos los ejercicios
  • Programas
  • Para principiantes

Guías

  • Fórmulas de Excel
  • Atajos de Excel

Empresa

  • Acerca de
  • Precios
  • Cómo corregimos

© GridBelt. Todos los derechos reservados.

  • Política de privacidad
  • Términos de uso
  • Política de reembolso

Excel es una marca comercial de Microsoft Corporation. Indeed, TestGorilla, SHL y otras marcas son propiedad de sus respectivos titulares. GridBelt es un sitio de práctica independiente y no está afiliado a Microsoft, TestGorilla, SHL ni Indeed, ni respaldado ni patrocinado por ellos.

  1. Práctica
  2. /
  3. IF function

IFERROR practice: margin % for 50 products without #DIV/0!

  • Intermedio
  • ~6 min
  • IF function

Enunciado en inglés

The buying team maintains a price list of 50 products with the unit cost (column D) and the selling price (column E). They report margin on cost — how much the selling price exceeds the cost, as a percentage of the cost: (price − cost) ÷ cost. 4 promotional items were received free from a supplier, so their cost is 0 and the division has no answer. The report must show n/a on those rows instead of an error, because the column is summarised further down the chain.

Qué tienes que hacer

  1. 1Click F2. The unit cost is in D2 and the selling price in E2; the margin on cost is (E2-D2)/D2.
  2. 2Wrap the division in IFERROR: the first argument is the calculation, the second is what to show when it fails — the text "n/a" in quotes.
  3. 3Press Enter and fill F2 down to F51 (double-click the fill handle, or select F2:F51 and press Ctrl+D / ⌘D). The column is already formatted as a percentage.
  4. 4Scroll to the promotional items (cost $0.00): they must read n/a, not #DIV/0!. Then click Check (Ctrl+Enter / ⌘+Return).

Celdas de respuesta

Corrección

Escribe tu fórmula en la cuadrícula, presiona Enter y luego haz clic en Comprobar. Evaluamos el valor de cada celda de respuesta y la fórmula que lo produce.

Tareas

  1. Sin comprobarIn F2, calculate the margin on cost, (E2-D2)/D2, so that the zero-cost rows show "n/a" instead of #DIV/0! — IFERROR is the usual tool — then fill the formula down to F51.

Para las tareas de hoja de cálculo se recomienda una pantalla grande. La hoja se desplaza dentro de este recuadro.

StartInsertFormulasDataView
A1fxPreparando tu libro…
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

Escribe tu fórmula en la hoja y luego comprueba.

Sobre este ejercicio

Un conjunto de datos de 50 filas en una hoja, una celda de respuesta, unos 6 minutos. Se corrige en tu navegador: el valor y la fórmula que lo produce, con comentarios que te dicen qué arreglar.

Cómo resolverlo

  • F2=IFERROR((E2-D2)/D2,"n/a")

Dividing by an empty or zero cost raises #DIV/0!, and one error cell is enough to break every AVERAGE or SUM that reads the column. IFERROR(value, value_if_error) returns the first argument when it computes normally and the second when it produces any error, so =IFERROR((E2-D2)/D2,"n/a") shows the margin for priced items and n/a for the four free ones. Filled down, the same formula handles every row without you knowing in advance which products have a zero cost.

Pitfall 1: IFERROR hides every error, not just #DIV/0! — a typo like (E2-D2)/D3 or a text value in column E is silently replaced by n/a too. When only the zero-cost case is expected, =IF(D2=0,"n/a",(E2-D2)/D2) is the more honest formula; IFERROR is the pragmatic choice when the data can hold several kinds of junk. Pitfall 2: returning 0 or "" instead of n/a changes the statistics — AVERAGE ignores text but counts a 0, so a 0% margin on free stock drags the average down. Pitfall 3: margin on cost (markup) is not margin on price: (E2-D2)/E2 never divides by zero here and gives a different, smaller number; always state which one a report uses. Alternatives: IFNA only catches #N/A (useful around lookups, useless here); in Excel 365, =LET(m,(E2-D2)/D2,IF(ISERROR(m),"n/a",m)) avoids computing the division twice. Formatting: the fallback text sits in a column formatted 0.0% — text ignores number formats, which is why n/a shows as typed.

Otras formas válidas

  • =IF(D2=0,"n/a",(E2-D2)/D2) — explicit test on the cost; only the expected error case is handled
  • =IF(ISERROR((E2-D2)/D2),"n/a",(E2-D2)/D2) — the pre-2007 pattern IFERROR replaced
  • =IFERROR(E2/D2-1,"n/a") — algebraically the same margin on cost

Errores frecuentes

Writing =IFERROR((E2-D2)/D2) with no second argument, or putting the fallback first — IFERROR needs the calculation first and the replacement value second, in quotes when it is text.

Cómo corregimos

Se acepta cualquier fórmula que produzca el resultado correcto, salvo que la tarea nombre una función: entonces otra función obtiene media puntuación. Comparamos los valores con una pequeña tolerancia y, en el texto, ignoramos mayúsculas y espacios. Un número correcto escrito a mano en lugar de una fórmula obtiene media puntuación. Las tareas de varias celdas obtienen la puntuación completa con el 100% de las celdas correctas y media puntuación desde el 50%. Cuando importa, también cambiamos una celda de entrada en una copia de tu hoja y comprobamos que tu fórmula se adapta.

Respuestas calculadas con las reglas de Excel 365 y comprobadas en nuestro corrector el 16 de noviembre de 2026. Autor: GridBelt team.

En estos programas

  • Excel for Data AnalystsDía 4
  • Excel for Accounting and BookkeepingDía 3
  • Learn Excel From ScratchDía 10

Ejercicios relacionados

  • Flag rows with missing dataIntermedio, ~5 min
  • Commission tiers with nested IF, IFS or a lookupIntermedio, ~8 min
  • Pass or Fail with IFPrincipiante, ~4 min

Referencia de la función

Documentación oficial

Siguiente ejercicio

Commission tiers with nested IF, IFS or a lookup