Thank you for your help. What you suggested work. However, it created a set of other issues:
1- In case of list items, not date, it only works for 1 value. Multiple or all values crashes
2- The report is now very slow, most probably due to the join, because tables shouldn't be joined since their data is rather different
I have a feeling i am heading in the wrong direction in this.
To solve my issue differently, is it possible to filter the data with a field that is not listed in the view? To make things clearer, I will give you an example:
The database consists of sales data. The table contains a list of customers, grouped by country, region, city and classification. Each customer has multiple types of freezers, and multiple freezers of each type. Therefore, the calculation of average sales is a weighted calculation, based on the number of freezers per type. Also, the table contains records for every month. Therefore, this is the content of my table:
- Country
- Region
- City
- Class
- Date (Month and Year)
- Customer
- FreezerType
- NbFreezers
- Sales
To calculate the average of Sales per customer, i have to
select Country, Region, City, Class, Date, Customer, FreezerType, Sum(Sales*NbFreezers)/Sum(NbFreezers)
from table
Group By Country, Region, City, Class, Date, Customer, FreezerType
On the other hand, I have to create another report that shows the percentage of invoiced customers versus non invoiced customers. An invoiced customer is a customer that has an average sales > 0 for the selected period, regardless of freezer type. So in this case, the view looks like this:
Select Country, Region, City, Class, Customer, CASE WHEN Sum(Sales) > 0 THEN 1 ELSE 0 END IsInvoiced
From table
Group By Country, Region, City, Class, Customer
Where Date between @DateFrom and @DateTo
Originally, I need to put both views in the same report. I tried with the technique you mentioned but I got the problems mentioned above. Moreover, I need to filter by Date also but the Date is not part of the list of the fields in the view.
Therefore, my questions are:
1- Is there a way to include both tables in the same report?
2- Is there a way to filter on a field that is not part of the field list?
3- Is there a different way to do it than the way i am doing it?
I know this is a lot of information but I am really stuck at this point.
Thanks a lot.
Jean-Yves