Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to merge records from two different fields from same table

Flag:

LOAD EmpID,Date,

   if(frac(min(Time))<=$(vEarlyTime),'Early','Late') as FlagEarly,

   if(frac(max(Time))>=$(vOverTime),'Over','Within') as FlagOver

Resident EmployeeTimeData

Group By EmpID,Date;

by using this i am getting

FlagEarly/Late             FlagOver/Within

Early                          Over

Late                            Within

But i want to have

Flag

Early

Late

Over

Within

i am trying with nested if something like

Flag1:

LOAD EmpID,Date,

     if(Frac(Min(Time))<=$(vEarlyTime),'Early',if(Frac(Min(Time))>$(vEarlyTime),'Late',if(Frac(max(Time))>=$(vOverTime),'Over',if(Frac(max(Time))<$(vOverTime),'Within')))) as Flag

   Resident EmployeeTimeData

Group By EmpID,Date;

but it is giving

Flag

Early

Late

so please help me how to achieve this

21 Replies
PrashantSangle

Hi,

not possible in single if statement.

If you want both in same field then try like

Flag:

LOAD EmpID,Date,

   if(frac(min(Time))<=$(vEarlyTime),'Early','Late') as Flag

Resident EmployeeTimeData

Group By EmpID,Date;

concatenate

LOAD EmpID,Date,

   if(frac(max(Time))>=$(vOverTime),'Over','Within') as Flag

Resident EmployeeTimeData

Group By EmpID,Date;

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Anonymous
Not applicable
Author

Dear, yes i know and i want to know the values for checking purpose and also helpfull for write script, kindly put the flag values manually as i mention above.

Regards,

Zain.


sasiparupudi1
Master III
Master III

Hi

What are the values in the variables

$(vEarlyTime) and $(vOverTime)

Not applicable
Author

set vEarlyTime=(7*60+10)/(24*60);

set vOverTime=16/24;

PrashantSangle

hi,

Did you try my suggetsion??

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

By using this i got the required answer but i am getting association between time and (early,Late)not getting association between time and(over,within)

Anonymous
Not applicable
Author

idEmpIDEventIDDateTimeminTimevEarlyTimevOverTimemaxTime
130015746008/02/20157:50:00 AM7:50:00 AM7:10:00 AM4:00:00 PM4:30:00 PM
230015746108/02/20158:20:00 AM7:50:00 AM7:10:00 AM4:00:00 PM4:30:00 PM
330015746008/02/20158:40:00 AM7:50:00 AM7:10:00 AM4:00:00 PM4:30:00 PM
430015746108/02/201510:30:00 AM7:50:00 AM7:10:00 AM4:00:00 PM4:30:00 PM
530015746008/02/201510:50:00 AM7:50:00 AM7:10:00 AM4:00:00 PM4:30:00 PM
630015746108/02/201511:30:00 AM7:50:00 AM7:10:00 AM4:00:00 PM4:30:00 PM
730015746008/02/201512:40:00 PM7:50:00 AM7:10:00 AM4:00:00 PM4:30:00 PM
830015746108/02/20152:50:00 PM7:50:00 AM7:10:00 AM4:00:00 PM4:30:00 PM
930015746008/02/20153:10:00 PM7:50:00 AM7:10:00 AM4:00:00 PM4:30:00 PM
1030015746108/02/20154:30:00 PM7:50:00 AM7:10:00 AM4:00:00 PM4:30:00 PM

Kindly fill flag value and revert.

Regards,

Zain.

sasiparupudi1
Master III
Master III

set vEarlyTime=(7*60+10)/(24*60);

set vOverTime=16/24;

Data:

LOAD id,

     EmpID,

     EventID,

     Date,

     //Date(Date#(subDate,'MM-DD-YYYY'),'MM-DD-YYYY') as Date,

     Time

FROM

(ooxml, embedded labels, table is Sheet1);

left join(Data)

//load EmpID,Date,  Time(min(Time),'hh:mm:ss') as MinTime,Time(Max(Time),'hh:mm:ss') as MaxTime Resident Data Group By EmpID,Date;

load EmpID,Date,  min(Time) as MinTime, Max(Time)  as MaxTime Resident Data Group By EmpID,Date;

NoConcatenate

final:

load  *, if(MinTime<=$(vEarlyTime),'Early','Late') as Flag Resident Data;

load  *, if(MaxTime>=$(vOverTime),'Over','Within') as Flag Resident Data;

drop Table Data;

hth

Sasi

Not applicable
Author

Hi,

Please find the attached QVW. !

Not applicable
Author

i dont have licensed version plz share script