Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Pivot table with dimensions calculated

Hello!

I have a problem with a pivot table and calculated dimensions:

I have a table with differents records; each record has a account (General_Numero).

For Example:

General_Numero Debe     Haber   Date

57200001          100          0          01/04/2012

43000000          200          0          01/04/2012

57200001          0            50          02/04/2012

43000000          300          0          02/04/2012

57200001          150          0          03/04/2012

I want to get the next:

                    01/04/2012     02/04/2012     03/04/2012

57200001          100              50                     200

43000000          200             500                    500    

I have a List Box to selecction only the account 572xxxxxxx; I want to the user selections a account 572xxx  and the pivot table has to show the account selected  + 4300000.

My dimension is : =valuelist(getfieldselections(General_Numero),'4300000')

My Expression is : =rangesum(Sum(Apunte_Debe-Apunte_Haber),before(Sum(Apunte_Debe-Apunte_Haber),1,ColumnNo()))

The problem is that both rows are the same ....

                    01/04/2012     02/04/2012     03/04/2012

57200001          100              50                     200

43000000          100              50                     200

When the user selects the account, the selected records, obviously, are those containing the account but I want to add  the records with the  account '4300000'.

I don´t know how to do this .....

Best Regards




1 Solution

Accepted Solutions
Not applicable
Author

Muchisimas gracias Sandro,

Había conseguido hacer algo parecido pero haciendo todos los cálculos dentro de la pivot table en lugar de hacerlo en el script.

Probaré a hacerlo según tu ejemplo ... puede que sea mejor hacerlo así para poder hacer el siguiente paso que es calcular el saldo inicial de las cuentas de banco para colocarlo como primera columna de la pivot table, (es decir, el acumulado que tienen antes de la fechas seleccionadas ....)

De nuevo, gracias por las molestias que te has tomado (además me ha servido para ver instrucciones que todavía no había utilizado ...).

Un saludo

View solution in original post

6 Replies
spividori
Specialist
Specialist

He.

See the example, hope this help!

Regards.

Not applicable
Author

Thank you very much!!

     The only problem I see is that there are multiple accounts 572xxxx (572000001, 57200002, etc...) in main table; If I have a List box to select the account, the pivot table only shows this account, not 572xxx and 430xxx .....

     I had tried something else ...

  Script:

F_ECRITUREC:

LOAD *, IF (Apunte_Sentido=0,Apunte_Importe,0) AS Apunte_Debe,

IF (Apunte_Sentido=1,Apunte_Importe,0) AS Apunte_Haber,

iF (Codigo_Nat>= 1 and Codigo_Nat <=5, General_Numero, null()) as Cuenta_Tesoreria;

SQL SELECT "F_ECRITUREC"."CG_NUM" as General_Numero,

   "CT_NUM" as Tercero_Numero,

   (EC_JOUR + JM_DATE)-1 AS Fecha,

   "EC_MONTANT" as Apunte_Importe,

   "EC_SENS" as Apunte_Sentido,

   "JO_NUM" as Diario,

   "EC_PIECE" as Apunte_Asiento,

   "EC_INTITULE" as Apunte_Descripcion,

   "EC_REFPIECE" as Apunte_Factura,

   "EC_ECHEANCE" AS Apunte_Vencimiento,

   "N_REGLEMENT" AS CodPago,

   "EC_LETTRE" AS Compensacion,

   "EC_NO" AS NumInterno,

   "N_NATURE" AS Codigo_Nat

FROM F_ECRITUREC INNER JOIN F_COMPTEG ON F_ECRITUREC.CG_NUM = F_COMPTEG.CG_NUM ORDER BY JM_DATE ASC;

The pivot table:

  Two dimensions:

  General_Numero

  Date

  Three Expressions:

Banco: =rangesum(Sum(Apunte_Debe-Apunte_Haber),before(Sum(Apunte_Debe-Apunte_Haber),1,ColumnNo()))

Clientes: =rangesum(Sum({$<Cuenta_Tesoreria = P({1<Cuenta_Tesoreria={'4300000'}>})>} Apunte_Debe-Apunte_Haber), before(Sum({$<Cuenta_Tesoreria = P({1<Cuenta_Tesoreria={'4300000'}>})>} Apunte_Debe-Apunte_Haber),1,ColumnNo()))

Proveedor: =rangesum(Sum({$<Cuenta_Tesoreria = P({1<Cuenta_Tesoreria={'4000000'}>})>} Apunte_Debe-Apunte_Haber), before(Sum({$<Cuenta_Tesoreria = P({1<Cuenta_Tesoreria={'4000000'}>})>} Apunte_Debe-Apunte_Haber),1,ColumnNo()))

Imagen1.jpg

I'll prefer your pivot table (Clientes, Proveedor in rows, not columns) ... I see you load all in scripts (acumulated imports, accounts...) and I have to test if it tabkes a long time to load data....

Best Regards

spividori
Specialist
Specialist

Pedro.

Por lo que leo entendés español, pasame algunos datos en un archivo excel así puedo armartelo como querés.

Saludos.

Sandro.

Not applicable
Author

Pues muchas gracias Sandro!

Te adjunto una hoja de Excel con unos datos ejemplo del mes de dicembre.

La idea es tener una List Box que muestre unicamente las cuentas de tesoreria que comiencen por 57* y que el usuario seleccione cualquier cuenta de banco (572xxxxxx).

La pivot table debe mostrar por día el saldo acumulado de la cuenta seleccionada y además, las cuentas 43000000 y 40000000 (que no las selecciona el usuario) para crear un saldo teórico.

Es decir, como filas la cuenta 572x seleccionada, la cuenta 430000 y la cuenta 400000 con sus respectivos importes y como columnas las fechas.

Para complicar mas la cosa, los registros que se deben seleccionar que contengan las cuenats 4300000 y 40000000 en General_numero deben ser unicamente los no compensados, es decir, que el campo EC_LETTRE = 0.

Muchisimas gracias otra vez !!

spividori
Specialist
Specialist

Hola Pedro.

Acá te dejo el ejemplo, me has hecho trabajar un tanto, espero que te sirva.

Saludos.

Not applicable
Author

Muchisimas gracias Sandro,

Había conseguido hacer algo parecido pero haciendo todos los cálculos dentro de la pivot table en lugar de hacerlo en el script.

Probaré a hacerlo según tu ejemplo ... puede que sea mejor hacerlo así para poder hacer el siguiente paso que es calcular el saldo inicial de las cuentas de banco para colocarlo como primera columna de la pivot table, (es decir, el acumulado que tienen antes de la fechas seleccionadas ....)

De nuevo, gracias por las molestias que te has tomado (además me ha servido para ver instrucciones que todavía no había utilizado ...).

Un saludo