Hi,
I am setting up a new database and need some assistance with my main query.
I have 3 tables:
tbl_LEI_Targets (define budget by productID - it is updated at each new LEI Version which means unique productID for each LEI_Version)
tbl_LEI_Version (this table maps LEI_version against Budget_version from the tbl_MAIN)
tbl_Main (budget broken down by Department/Business units/Markets...)
What I need to do:
Create a query that will help me reconcile the [tbl_LEI_Target] and the [tbl_Main] when 4 criterias are met: type/Year/Version/ProductID
tbl_LEI_Targets.[ProductID] = tbl_Main.[ProductID]
tbl_LEI_Targets.Year=tbl_Main.Year
tbl_LEI_Targets.Type=tbl_Main.Type
I can do the query with these 3 criterias but I am struggling to get a result to tie to "version". I have tried different relationships with no success.
tbl_LEI_Targets.LEI Version is mapped to the tbl_Main through the tbl_LEI_Version
my sql with 3 criterias is:
SELECT tbl_Main.ProductID, tbl_LEI_Targets.ProductID, tbl_LEI_Targets.[LEI Version], Sum(tbl_LEI_Targets.Value) AS SumOfValue, tbl_Main.Year, tbl_LEI_Targets.Year, tbl_LEI_Targets.Type, tbl_Main.Type, tbl_LEI_Targets.Year, tbl_Main.ProductID, Sum([tbl_LEI_Targets]![Value]-[tbl_Main]![Quantity]) AS Var, Sum(tbl_Main.Quantity) AS SumOfQuantity
FROM tbl_LEI_Targets LEFT JOIN tbl_Main ON tbl_LEI_Targets.ProductID = tbl_Main.ProductID
WHERE (((tbl_LEI_Targets.Year)=[tbl_Main].[Year]) AND ((tbl_LEI_Targets.Type)=[tbl_Main].[Type]))
GROUP BY tbl_Main.ProductID, tbl_LEI_Targets.ProductID, tbl_LEI_Targets.[LEI Version], tbl_Main.Year, tbl_LEI_Targets.Year, tbl_LEI_Targets.Type, tbl_Main.Type, tbl_LEI_Targets.Year, tbl_Main.ProductID;
I am attaching the DB.
I am pretty sure it's easy but I have now spent hours on it ... thank you for your help!
Chatholo