Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Previous or other function?

  Hi all,

I have this:

CompanyIDJobDateNorm
123413-2-20132
56785-1-20132
56781-6-20153

I want this:

CompanyIDJobDateNorm
12313-2-20132
1231-1-20142
1231-1-20152
56785-1-20132
56781-1-20142
56781-6-20153

In the first table table I have only record at Jobdate, bus for an intervalmatch() I need also records for all the other years till now.

Thanks!

Best regards,

Arjan

1 Solution

Accepted Solutions
maxgro
MVP
MVP

RESULT


1.png

SCRIPT

source:

LOAD Distinct

  CompanyID

FROM source.qvd (qvd);

tmp: load min(year(JobDate)) as MinJobYear From source.qvd (qvd);

let vMinJobYear = Peek('MinJobYear');

DROP Table tmp;

join (source)

load $(vMinJobYear) + rowno() -1 as JobYear

AutoGenerate (year(Today())-$(vMinJobYear)+1);

Left join (source)

LOAD

  CompanyID,

    JobDate,

  year(JobDate) as JobYear,

    Norm

From source.qvd (qvd);

final:

NoConcatenate load

  CompanyID,

    if(len(trim(JobDate))=0, date(MakeDate(JobYear)), JobDate) as JobDate,

  JobYear,

    if(len(trim(JobDate))=0, peek(Norm), Norm) as Norm

Resident source

order by CompanyID,   JobYear; 

DROP Table source;

View solution in original post

2 Replies
maxgro
MVP
MVP

RESULT


1.png

SCRIPT

source:

LOAD Distinct

  CompanyID

FROM source.qvd (qvd);

tmp: load min(year(JobDate)) as MinJobYear From source.qvd (qvd);

let vMinJobYear = Peek('MinJobYear');

DROP Table tmp;

join (source)

load $(vMinJobYear) + rowno() -1 as JobYear

AutoGenerate (year(Today())-$(vMinJobYear)+1);

Left join (source)

LOAD

  CompanyID,

    JobDate,

  year(JobDate) as JobYear,

    Norm

From source.qvd (qvd);

final:

NoConcatenate load

  CompanyID,

    if(len(trim(JobDate))=0, date(MakeDate(JobYear)), JobDate) as JobDate,

  JobYear,

    if(len(trim(JobDate))=0, peek(Norm), Norm) as Norm

Resident source

order by CompanyID,   JobYear; 

DROP Table source;

Anonymous
Not applicable
Author

Thanks Massimo Grossi!!