Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
i want to show you an strange issue.
I have the table 1.
I don't know why but when i use the sum expression the values are wrong (see table 2))...
The real value of sum is 51.
Can someone help me?
Thanks!
Hi,
As already mentioned earlier by Jagan, your table has got duplicate keys.
I have added one chart which describes how many times your keyfield is duplicated. Total of the same is number of rows appearing in your subsription table.
Sum of the field is also justified as breakup explains the same.
Regards
Amar Nath
Hi,
Hope attached file helps you.
Regards,
Sampath Kumar G
Thank you very much Sampath, Amar and Jagar....
What can i do to resolve the problem of Key duplication with the inner join?
Hi,
If you want to eliminate duplicate rows try using Distinct during load.
LOAD DISTINCT
*
FROM DataSource;
This will remove the duplicate rows.
Or
If you want to keep all the rows as such
introduce a new field like RowNo(). Check file attached in above post.
Regards,
jagan.
Thanks Jagan!
So….if i need to use inner join between two tables then i have to use a distinct load?
I mean, always inner join create duplícate keys? there is another function to use to avoid this?
Enviado el: viernes, 20 de abril de 2012 11:55 a.m.
Para: Pauza, Gerardo
Asunto: - Re: sum expression error
QlikCommunity <http://community.qlik.com/index.jspa>
Re: sum expression error
created by jagan mohan <http://community.qlik.com/people/jagan> in New to QlikView - View the full discussion <http://community.qlik.com/message/212402#212402
Hi Gera!!!
Usá
Sum(Aggr(Max( DEAL_EXTERNALS.quantity_A), DEAL_EXTERNALS.deal_externals_id_A))
, y podés dejar el script así como está.
El problema está en que tenés todos los valores repetidos un montón de veces. Inner Join no te duplica valores, Inner Join te quita las no coincidencias entre las tablas. Los valores duplicados podés tenerlos en cualquiera de los dos qvd que joineás.
Probalo!!
Sebastian,
gracias por la respuesta.
Lo que no llego a entender es porque tengo los valores duplicados, si lo unico que hago es hacer un inner join entre dos tablas con distinta informacion salvo por el user_id.
Cual seria la forma correcta de unir estas dos tablas sin generar duplicados?
Te paso el inner join que tengo ahora:
SUBSCRIPTIONS_A:
LOAD
user_id as %Key_USER_ID_A,
user_id as user_id_A
FROM [..\QVD\SUBSCRIPTIONS.QVD] (qvd);
inner Join
load
Year(created) & Num(Month(created),'00') & Num(Day(created),'00') as %Key_CREATED_DEAL_EXTERNALS,
user_id as %Key_USER_ID_A,
user_id as user_id_A,
quantity as quantity_A,
id as deal_externals_id_A
FROM [..\QVD\DEAL_EXTERNALS.QVD] (qvd)
where `external_status` = 'A';
Gracias
gerardo
hay que ver qué hay en los QVD...Intuyo q están en SUBSCRIPTIONS. Qué hay acá? Lo más probable es que tengas varios registros por cada user_id.
Le estás diciendo a Qlikview:
1- Leé las claves de SUBSCRIPTIONS.QVD y creá dos campos con nombres diferentes por cada una (acá es muy probable que estén repetidos)
2- Leé de DEAL_EXTERNALS.QVD tales datos, y emparentalos con cada clave leída.
Si tenés por ejemplo user_id A, A, A, B, B, C, C, C, C,... te va a poner los datos de quantity que se corresponden en la segunda tabla con A, 3 veces, con B, 2, y así....
Tenés que tener un buen conocimiento de qué hay en cada qvd antes de leerlo.
Perfecto! Excelente explicación.
Gracias
gerardo
Enviado el: lunes, 23 de abril de 2012 01:56 p.m.
Para: Pauza, Gerardo
Asunto: - Re: sum expression error
QlikCommunity <http://community.qlik.com/index.jspa>
Re: sum expression error
created by Sebastian Pereira <http://community.qlik.com/people/sebastiandpereira> in New to QlikView - View the full discussion <http://community.qlik.com/message/212893#212893
Dame un Resuelto! je