I'd like to make an overview of projects.
This contains some fixed info; table projects joined with some other tables.
Now the report needs to have some subqueries: how many sales per salesman, how many is in transit, inventory, ... and so on.
I have a tablix with grouping on project (as to create an excel with one worksheet per projet).
How would I go about executing a new subquery per project (f.e. select owner, sum(totalprice) from opportunities where project=xxx group by owner)
I know I could achieve this with subreports; but as I will have about 10 subreports, I was hoping I could solve this with extra datasets and some filtering (and thus keep all logic in one file).
What's the best way to achieve this?
I would create a dataset with this query:
select owner, project, sum(totalprice) as totalprice from opportunities group by owner, project
Next, in your tablix where you want to display owner and totalprice info, you will have an expression like this:
=LOOKUP(Fields!<FirstDataSetProjectFieldName>.Value, Fields!project.Value, Fields!owner.Value, "<NewDatasetName>")
The above code will send the value of the project you are searching for, match it with a the same field in your new dataset, then return the requested value from the new dataset. You can obviously do this for totalprice as well.
Check out the documentation for LOOKUP to get a better handle on it but I think this is the solution you are looking for.
Related
I am using Oracle Business Intellgience (12c) and let's say I have a report resulted from an execution of the following query
select code_filial, max(paid) as maximum_pay
from leads_history
group by code_filial
It will return a table with highest budget value related to the each filial. Now what i want is the following: when i click to max(paid) result in a table, another table should appear with the information about max(paid) account. I tried master-detail relationship, but couldn't succeed.
Can anyoune help with that?
That's out-of-the-box functionality. As soon as you make a navigation action link to another analysis where your code_filial is set to "is prompted" the context will be passed and the analysis filtered.
I have a report that shows maintenance information for medical instruments. The selection criteria are based on several tables and fields. I needed to change the criteria, but results were not as expected. I managed to find the cause, but do not know what to do to get to the wanted situation.
So basically the problem is as follows:
I have 2 tables that are linked:
* Equipment (information related to a specific instrument eg EqmId)
* ObjectFeature (information related to a specific feature eg ObjfEqmId, ObjfId, ObjfYesno)
An equipment can have 0, 1 or many ObjectFeatures, and the tables are linked via
Equipment.EqmId -> ObjectFeature.ObjfEqmId with a left-outer join.
The problem I have is that i want to filter out al EqmId's where (ObjfId="64" and ObjfYesno=1). I do not want to see these EqmId's in the final list.
In my current setup, I have only removed the ObjfId="64" lines, but since an EqmId can have multiple features, it still is present in the list...
In my original report Equipment is my main table, so I need a way to filter this table before I do further filtering and joining.
I find myself limited in the selection formula, and thought of using a SQL command on the database. But I can't get my head around how to do this.
How and where should I do the filtering?
I'm using Crystal Reports 14 with an Oracle DB. If I have related tables Authors and Books and I selects all the authors that have book with 'code' in their title Crystal will put Books.title in the SQL SELECT clause, even if I don't use any Books fields anywhere in the report (except for the record selection). The query looks like this:
SELECT "AUTHORS"."NAME", "BOOKS"."TITLE"
FROM "AUTHORS" INNER JOIN "BOOKS" ON "AUTHORS"."ID"="BOOKS"."AUTHOR"
WHERE "BOOKS"."TITLE" LIKE '%code%'
This causes a problem because, even if I use the "Distinct" option, I will get many entries for each author (if they have more then one book with 'code' in the title). But what I want is only one entry by author. "Distinct" do not work here because each entry is really distinct, their book title are different.
How can I avoid getting "BOOKS"."TITLE" in the SELECT clause like this:
SELECT DISTINCT "AUTHORS"."NAME"
FROM "AUTHORS" INNER JOIN "BOOKS" ON "AUTHORS"."ID"="BOOKS"."AUTHOR"
WHERE "BOOKS"."TITLE" LIKE '%code%'
If that's not possible, what's the best workaround to get distinct authors in my scenario?
UPDATE
I should add that currently I'm using this formula in the Suppress details section:
{AUTHORS.ID} = previous({AUTHORS.ID})
The problem with this solution and also the group solution proposed by #Beth is that the query is the same and the DB return too much data for no reason. In both solutions the data is filtered/regrouped in Crystal Reports, not in the DB.
can you group by authors in your report and suppress the books.title details?
to group by author, in your report, under the Insert menu, select 'Group...' then select author.id in the first combo box and click OK. You'll notice your report has changed to introduce Group Header and Footer sections above and below the detail section. You can suppress the detail section and only the authors will print.
If you want only the authors to come across, you'll need to use a command sent to the data source with the SQL you want used, instead of using the tables directly like you are now.
You can create a command as your back-end with your parameter in it. You'll use that parameterized command instead of the tables you're using now. Try creating the command without the parameter first, then after you get that working, you can add your existing parameter into the command SQL.
What I'm trying to do:
I have a report already created that looks for something existing in one database and not in another. 99% of the time the report comes up empty. We do not need to know when there are no results to show. I only want to know when the query returns a result.
What I've done so far:
I have a the Data Source created and a table (view) created to where I can query for Subscriber information.
What I hope can be answered:
Is it all possible to have this report run and email my selected Subscribers only when there is data in the output?
I see you've already looked into Data-Driven subscriptions. You should be able to write your query in the data-driven subscription to test if the report should return results, and if not, send it to a dummy address, and only send it to your subscriber list if there will be data in it.
If you put the dummy address in your table with an IsDummy flag column, you could do something like this:
SELECT [EmailTo]
FROM SubscriptionTable
WHERE IsDummy=0
AND (SELECT COUNT(*) FROM SomeTable)>0 --report should have results
UNION ALL
SELECT [EmailTo]
FROM SubscriptionTable
WHERE IsDummy=1
AND (SELECT COUNT(*) FROM SomeTable)=0 --report should not have results
And that's only one way, there are probably lots of other ways that might suit your needs as well or better.
My question is a variation on one already asked and answered (TSQL Delete Using Inner Joins) but I have a different level of complexity and I couldn't see a solution to it.
My requirement is to delete Special Prices which haven't been accessed in 90 days. Special Prices are keyed on Customer ID and Product ID and the products have to matched to a Customer Order Detail table which also contains a Customer ID and a Product ID. I want to write one function that will look at the Special Price table for each Customer, compare each Product for that Customer with the Customer Order Detail table and if the Maximum Order Date is more than 90 days earlier than today, delete it from the Special Price table.
I know I can use a CURSOR (slow but effective) but would prefer to have a single query like the one in the TSQL Delete Using Inner Joins example. Any ideas and/or is more information required?
I cannot dig more on the situation of your system but i think and if it is ok for you, check MERGE STATEMENT, it might be a help instead of using cursors. check this Link MERGE STATEMENT