You can use CASE
to compare the the tipo column to the value needed:
select id,
id_pedido,
p.id_articulo,
p.descripcion,
p.fecha,
u.nombre,
p.local,
case when a.tipo = 'X' then a.inicia+a.entra-a.sale end Existencias,
a.tipo
from pedidos p
join usuarios u on p.id_usuario=u.id_usuario
join articulos a on a.id_articulo=p.id_articulo
where estado='activo'