Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I´ve 2 tables like:
TABLE_1
PK,
CODIGO,
NR_ANO,
NR_MES
TABLE_2
PK,
NR_ANO_INICIO_COMPETENCIA,
NR_MES_INICIO_COMPETENCIA
I need count CODIGO while NR_ANO = NR_ANO_INICIO_COMPETENCIA.
I´m using this expression:
=Count({$<NR_ANO = NR_ANO_INICIO_COMPETENCIA>} DISTINCT CODIGO) but isn´t work.
Well, I still think that
=Count({$<NR_ANO = {"=NR_ANO=NR_ANO_INICIO_COMPETENCIA"} >} DISTINCT CODIGO)
should work. It's hard to help you if you don't give some more information...
If it's about performance, a distinct count on large data volume is probably always performing not very well.
You could try some of the methods e.g. described in the manual to improve performance on distinct counts.
For example, you could create a new table
LOAD DISTINCT
CODIGO, 1 as CODIGO_DIST
resident TABLE_1;
then do a sum( .... CODIGO_DIST) instead of the count( distinct .... CODIGO)
This will only work if you select on NR_ANO_INICIO_COMPETENCIA.
Try this:
=Count({$<NR_ANO = p(NR_ANO_INICIO_COMPETENCIA) >} DISTINCT CODIGO)
Or do you need a record based comparison on these two fields?
If you do need a record based comparision, try
=Count({$<NR_ANO = {"=NR_ANO=NR_ANO_INICIO_COMPETENCIA"} >} DISTINCT CODIGO)
Hi Swuehl,
I tried to use this expression like that you, but doesn´t work to.
I need count CODIGO when NR_ANO = NR_ANO_INICIO_COMPETENCIA
Thak you
Have you tried my second expression? If you say, it doesn't work, do you get no results, zero or something, but obviously wrong? Any details on what you are getting back and what do you expect might help.
You could also try an expression without a set expression:
=count(distinct if(NR_ANO = NR_ANO_INICIO_COMPETENCIA, CODIGO))
BTW, are you using QV10 or some older version?
Regards,
Stefan
Hello!
This works fine, but for small amount of records...
Well, thank for your help, and if there is another ideia, please, send me.
Joao
Well, I still think that
=Count({$<NR_ANO = {"=NR_ANO=NR_ANO_INICIO_COMPETENCIA"} >} DISTINCT CODIGO)
should work. It's hard to help you if you don't give some more information...
If it's about performance, a distinct count on large data volume is probably always performing not very well.
You could try some of the methods e.g. described in the manual to improve performance on distinct counts.
For example, you could create a new table
LOAD DISTINCT
CODIGO, 1 as CODIGO_DIST
resident TABLE_1;
then do a sum( .... CODIGO_DIST) instead of the count( distinct .... CODIGO)