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

FirstSortedValue()

I have two Tables:

Table 1 (Tax):

ID
DateFrom
Percent

Table 2 (Invoice):

InvNr
InvDate
Amount
TaxID

The Problem I have is, that I need the Percent from Table 1 where table1.ID=table2.TaxID and the last Date where table1.DateFrom<=table2.InvDate

In SQL I would describe it as:

select
table1.Percent
from table1, table2
where table1.ID=table2.TaxID and table1.DateFrom<=table2.InvDate
order by table1.DateFrom desc Limit 1

but I have no idea how to say it in QlikView.

 

2 Replies
fosuzuki
Partner - Specialist III
Partner - Specialist III

You can use IntervalMatch() function. More info here.

Example:

IntervalTable:

LOAD Key, ValidFrom, Team from IntervalTable.xls;

NullAsValue FirstDate,LastDate;

 

Key:

LOAD

Key,

ValidFrom as FirstDate,

date(if(Key=previous(Key),

previous(ValidFrom) - 1)) as LastDate,

Team

RESIDENT IntervalTable order by Key, ValidFrom desc;

 

drop table IntervalTable;

 

Transact:

LOAD Key, Name, Date, Sales from Transact.xls;

 

INNER JOIN intervalmatch (Date,Key) LOAD FirstDate, LastDate, Key RESIDENT Key;

 

Brett_Bleess
Former Employee
Former Employee

If the other partners suggested worked, we would appreciate it if you would close out the thread by using the Accept as Solution button on that post to mark things.  This will give them credit for the assistance and let the other Community Members know it helped.  If you did something different, you can post that and then mark that post, and if you still require assistance, please leave an update post.

You can also search the Design Blog area for further potential ideas too:

https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.