Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
maxwellf
Contributor III
Contributor III

Erro ao usar Max()

tabela.png

 

 DataUltRepo: 

LOAD
"nr-ord-produ",
"dat-fim-operac" as dataFim,
Max ("num-operac-sfc") as ultimoReporte
resident [Ord-Prod]
group by "nr-ord-produ"
;

 

Olá,

Estou usando código acima para gerar uma tabela com os seguintes dados: ordem, data final e ultimo reporte.

Preciso pegar somente a data do maior valor de num-operac-sfc, mas está dando o erro

 

erro.png

 

 

 

 

 

 

 

 

Existe alguma outra alternativa?

5 Replies
Saravanan_Desingh

Try this. The Case of nr-ord-produced is different in the Group By

DataUltRepo: 

LOAD
"nr-ord-produced",
"give-um-Operace" as dataFim,
Max ( "num-Operace-c") as ultimoReporte
residence [Ord-Prod]
group by "nr-ord-produced"
;

 

md_anasabbasi
Contributor III
Contributor III

You need to add both the fields("nr-ord-produ" and "dat-fim-operac" )in group by clause like this

LOAD
"nr-ord-produ",
"dat-fim-operac" como dataFim,
Max ("num-operac-sfc") como ultimoReporte
residente [Ord-Prod]
grupo por "nr-ord-produ", "dat-fim-operac";

 

Please mark the answer right if it solves your problem.

maxwellf
Contributor III
Contributor III
Author

Resolve o erro, mas traz mais de um "nr-ord-produ" igualcontinua.png

 

 

md_anasabbasi
Contributor III
Contributor III

This is because for one "nr-ord-produ" there are two dates(dataFim). If you only wants the second row from '332611' irrespective of dates. Go for this script-

LOAD
"nr-ord-produ",
// "dat-fim-operac" como dataFim,                     -- Commented to bring the max value irrespective of date
Max ("num-operac-sfc") como ultimoReporte
residente [Ord-Prod]
grupo por "nr-ord-produ";

 

Please mark the answer right if it solves your problem.

maxwellf
Contributor III
Contributor III
Author

Mas preciso do "dat-fim-operac"