Search code examples
pivot-tablemdxpowerpivotexcel-2019

SUM two rows in PowerPivot Pivot table MDX Balance Sheet Subtotal for Liabilities + Equity


Really new to MDX and have researched for hours but haven´t found the way to make it work.

Objective: Sum two rows (liabilities-pasivos and equity-patrimonio) for a pivot table that represents a balance sheet.

Background: Data is currently in the data model and the report is working as expected. I just need to add at the bottom a new row that sums those two rows.


Current report:

enter image description here


Expected result:

enter image description here


Current MDX code:

{([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[EFECTIVO Y EQUIVALENTES AL EFECTIVO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[INVERSIONES CP]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[CUENTAS POR COBRAR]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[CUENTAS POR COBRAR].&[Cuentas por cobrar a costo amortizado]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[CUENTAS POR COBRAR].&[Cuentas por cobrar de dificil recaudo]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[CUENTAS POR COBRAR].&[Deterioro acumulado de cuentas por cobrar (Cr)]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[CUENTAS POR COBRAR].&[Otras cuentas por cobrar]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[CUENTAS POR COBRAR].&[Prestación de servicios]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[CUENTAS POR COBRAR].&[Prestación de servicios públicos]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[CUENTAS POR COBRAR].&[Ventas de bienes]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[CUENTAS POR COBRAR]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[PRESTAMOS POR COBRAR]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[INVENTARIOS]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[INVENTARIOS].&[Bienes producidos]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[INVENTARIOS].&[En transito]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[INVENTARIOS].&[Materiales y suministros]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[INVENTARIOS].&[Materias primas]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[INVENTARIOS]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE].&[OTROS ACTIVOS]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO CORRIENTE]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO NO CORRIENTE]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO NO CORRIENTE].&[PROPIEDAD, PLANTA Y EQUIPO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO NO CORRIENTE].&[PROPIEDAD, PLANTA Y EQUIPO].&[PROPIEDAD, PLANTA Y EQUIPO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO NO CORRIENTE].&[PROPIEDAD, PLANTA Y EQUIPO].&[Depreciación acumulada de propiedad, planta y equipo]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO NO CORRIENTE].&[PROPIEDAD, PLANTA Y EQUIPO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO NO CORRIENTE].&[OTROS ACTIVOS]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO].&[ACTIVO NO CORRIENTE]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[18].&[ACTIVO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[PRESTAMOS POR PAGAR CP]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[CUENTAS POR PAGAR]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[CUENTAS POR PAGAR].&[Adquisición de bienes y servicios nacionales]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[CUENTAS POR PAGAR].&[Creditos Judiciales]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[CUENTAS POR PAGAR].&[Descuentos de Nomina]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[CUENTAS POR PAGAR].&[Impuesto al Valor Agregado IVA]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[CUENTAS POR PAGAR].&[Impuestos Contribuciones y Tasas por pagar]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[CUENTAS POR PAGAR].&[Otras Cuentas por Pagar]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[CUENTAS POR PAGAR].&[Recursos a favor de terceros]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[CUENTAS POR PAGAR].&[Retención en la Fuente e impuesto de Timbre]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[CUENTAS POR PAGAR]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[BENEFICIOS A LOS EMPLEADOS]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[OPERACIONES CON INSTRUMENTOS DERIVADOS]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[OTROS PASIVOS]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[OTROS PASIVOS].&[Avances y anticipos entregados]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[OTROS PASIVOS].&[Depósitos recibidos en garantía]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[OTROS PASIVOS].&[HONORARIOS]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[OTROS PASIVOS].&[Otros Servicios-Asistencia Tec]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[OTROS PASIVOS].&[Recursos Recibidos en administración]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[OTROS PASIVOS].&[Venta de servicio de energía corto plazo]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE].&[OTROS PASIVOS]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO CORRIENTE]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[PRESTAMOS POR PAGAR LP]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[PRESTAMOS POR PAGAR LP].&[Arrendamiento Financiero  LP]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[PRESTAMOS POR PAGAR LP].&[Intereses por pagar]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[PRESTAMOS POR PAGAR LP].&[Prestamos Banca Comercial L.P.]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[PRESTAMOS POR PAGAR LP]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[CUENTAS POR PAGAR]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[CUENTAS POR PAGAR].&[Subvenciones por pagar]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[CUENTAS POR PAGAR]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[OTROS PASIVOS NO CORRIENTES]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[OTROS PASIVOS NO CORRIENTES].&[Pasivos por Impuestos Diferidos]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[OTROS PASIVOS NO CORRIENTES].&[Venta de Servicio de Energía Largo Plazo]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE].&[OTROS PASIVOS NO CORRIENTES]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO].&[PASIVO NO CORRIENTE]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[20].&[PATRIMONIO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[20].&[PATRIMONIO].&[CAPITAL SUSCRITO Y PAGADO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[20].&[PATRIMONIO].&[GANANCIA O PERDIDA POR COBERTURA FLUJOS DE EFECTIVO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[20].&[PATRIMONIO].&[IMPACTOS POR LA TRANSICIÓN AL NUEVO MARC]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[20].&[PATRIMONIO].&[RESULTADO DEL EJERCICIO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[20].&[PATRIMONIO].&[RESULTADOS EJERCICIOS ANTERIORES]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[20].&[PATRIMONIO])}

I have tried to add this code at the end:

SUM(([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[20].&[PATRIMONIO]),([TablaConfigReporte].[Jerarquía reporte].[Codigo reporte].&[19].&[PASIVO]))

but it throws this error: enter image description here

Any help would be really appreciated...

EDIT: After researching, I found out that this is not possible with MDX when you are using the DataModel with sources like an Excel table. If there's somebody that proves me wrong. Please be my guest. See the answer of how I ended up


Solution

  • If this is helps somebodyelse. This is how I ended up solving it:

    1) I created a cascade subtotal as described here: https://powerpivotpro.com/2011/09/profit-lossthe-art-of-the-cascading-subtotal/

    2) In the measure, I filtered out the label called "Assets". That left the subtotal including only Liabilities and Equity.