I am familiar with how to merge dimensions where I have two queries and a common object where I want to match on when their values are equal. But what about if I want to connect on something other than equality (<, between, etc.)?
Here is what my sample data looks like (top two tables) and the result want (the bottom table)…
In SQL Server this is easy…
SELECT
x.ID
, x.CustomerID
, x.SomeDate
, COALESCE (y.SomeValue, 0) AS [SomeValue]
FROM #Table1 x
LEFT JOIN #Table2 y ON x.CustomerID = y.CustomerID
AND x.SomeDate BETWEEN y.StartDate AND y.EndDate;
Here is a dbfiddle demo with sample data.
If you want to you can pull the SQL for each table from the demo and put them in free-hand SQL queries to simulate this in Web Intelligence.
In Web Intelligence I am merging on CustomerID. I created detail variables for StartDate, EndDate, and SomeValue from my second query with my merged CustomerID as the associated dimension. Then created a variable name Var SomeValue Reference with the following formula (source data in top two tables, result in the bottom table)…
=[Var SomeValue] Where([SomeDate] Between([Var StartDate]; [Var EndDate]))
I am really close. After checking either “Avoid duplicate row aggregation” or “Show rows with empty dimension values” to get rid of #MULTIVALUE everywhere I get this…
However, ID 4 should also have a Var SomeValue Reference value of 350 since its SomeDate value is between 2022-06-21 and 2022-06-29.
What am I doing wrong? Is this possible?
Thanks,
Noel