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

Problem with Group By Sentence

Hi all,

I'm having a problem with a simple group by, and I can't guess why.

I have a text file with a few records, and I need to load just the newest records for each value

I'm trying this but doesn't work.

Seguimiento:

LOAD

  %KEY_Incidente_Seguimiento,

  [Comentario Gerencia],

  [Status Follow Up],

  Date([Target Date]) AS [Target Date],

  Modificado as FechaModificacion

FROM [$(APP)\QVD\Seguimiento.txt]

(txt, utf8, embedded labels, delimiter is ';', msq)

;

Load

%KEY_Incidente_Seguimiento,

FechaModificacion

Resident Seguimiento

Where Floor(FechaModificacion) = Max(Floor(FechaModificacion))

Group by %KEY_Incidente_Seguimiento;

Hope you can help me!

Thanks!

1 Solution

Accepted Solutions
jyothish8807
Master II
Master II

hi Jonathan,

try like this:

Load

%KEY_Incidente_Seguimiento,

Max(Floor(FechaModificacion)) as ABC

Resident Seguimiento

Group by %KEY_Incidente_Seguimiento;


regards

KC

Best Regards,
KC

View solution in original post

7 Replies
MK_QSL
MVP
MVP

Is FechaModificacion a timestamp?

jyothish8807
Master II
Master II

hi Jonathan,

try like this:

Load

%KEY_Incidente_Seguimiento,

Max(Floor(FechaModificacion)) as ABC

Resident Seguimiento

Group by %KEY_Incidente_Seguimiento;


regards

KC

Best Regards,
KC
Not applicable
Author

This value comes from a Qlik chart. and then stored into a txt.

I set the field by this way:

FechaModificacion = Today();

So the format shown is = "20/10/2014 12:28:30 PM" , when I make a Floor(FechaModificacion) I get the numeric value used by Qlik to manage dates. I show it into a Text box and y see 41932, so it works fine.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

In a load with GROUP BY clause, you cannot list columns that don't appear in the GROUP BY clause. They must to be used in an aggregation function, like:

Load

%KEY_Incidente_Seguimiento,

Max(FechaModificacion) AS FechaModificacion

Resident Seguimiento

Group by %KEY_Incidente_Seguimiento;

This will build a table with the last modification date/time for every incident.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Use the FirstSortedValue() aggregation function to lift other fields of the most recent record.

MK_QSL
MVP
MVP

What is your objective to use this code? Can you please clarify little more... IF possible, pls provide some sample data...

Not applicable
Author

Thanks this works perfectly, i'm sure i tried it but I made a mistake I guess.

TY again.

Regards!