Discussion Board for collaboration on QlikView Scripting.
So, I have a table:
And then I have two other tables which tells me if DepartmentID and/or EmployeeID should be excluded from analysis reports in certain periods of time:
My wish is to create a new field in my fact table called 'Exclude' which contains the values 'Yes' or 'No'.
The value must be 'Yes' if either DepartmentID OR EmployeeID can be matched in their respective exclusion lists AND if the FactDate falls in between the start date and end date in the given list.
I'm thinking something like this:
DepartmentID= Exc_DepartmentID AND (FactDate>= dStartDate AND FactDate<= dEndDate)
EmployeeID = Exc_EmployeeID AND (FactDate>= eStartDate AND FactDate<= eEndDate)
,'Yes','No') as Exclude
Note: The end dates can be null, meaning that the exclusion is ongoing (until an end date is specified in the list).
So how can I achieve my goal? I'm thinking that I somehow need to do some joining and use resident loads, but I have very little idea of how to do it.
Go to Solution.
I'd suggest IntervalMatch for this.
LEFT JOIN (FactTable)
1 as DepartmentExclusion
DROP TABLE DepartmentExclusions;
Repeat for ExployeeExclusionList
At first I couldn't get it to work, but after reading a bit about the IntervalMatch function and then altering your code a little bit, I was able to make it work.