COGNOS report for a simple sub query and join Query - cognos

Here is my query. I am new to Cognos and using Cognos 10. And I am having a bit difficulty in developing a report which uses a Sub Query and an Inner Join Query.
1.
SELECT ID, BATCH_DT, LOCIT FROM AOI.TEMP_BRICK
WHERE BATCH_DT < (SELECT MAX(DATE) FROM CALENDAR)
2.
SELECT A.ID, B.SAL FROM TABLE as A LEFT OUTER JOIN TABLE as B
WHERE A.ID=B.ID

First, you must understand that Cognos generates its own SQL. In order for it to do that, you must define relationships between tables in Cognos Framework Manager. Once that is done your report has 3 major parts, The Report Page(s), the Prompt Page(s) and the Query(s).
a.) Setup the CALENDAR and AOI.TEMP_BRICK tables in Cognos. You may want to define a relationship between TEMP_BRICK.BATCH_DT and CALENDAR.DATE (assuming your calendar has date records for every date that may be present in TEMP_BRICK).
b.) Next you would create a new List Report. You would grab your ID, BATCH_DT and DATE fields into the list. (Date would come from the calendar if you decided to link the two tables in step A, otherwise you use the BATCH_DT field in TEMP_BRICK.)
c.) You would open the Query pages and see that Cognos has already created one query, called Query1. You need to create a new query (we will call it qryMaxDate). That query would have one element, 'DATE' from CALENDAR. On the properties of the 'DATE' field in Data Items, you would chagne the 'Agregate Function' from None to 'Maximum'.
d.) Now edit your Query1, add a Filter on the Date from that query. In the Expression Definition, select the Queries tab and drag the 'DATE' field from your qryMaxDate. Should look something like this [Batch Date] = [qryMaxDate].[Date]
e.) You are done! Run the report. in this case, the user running the report is giving no input, so no Prompt page is necessary.
a.) Setup Table A and B in the Framework Manager. You need to define a relationship between Table A and B in Framework Manager via a Star Schema (define A.ID = B.ID and specify 1 to n, or n to 1).
b.) Create a new report and simply drag in elements from table a and table b. Their relationship is already defined in Framework manager, so there is no need to re-define it while writing reports.
Your second example is a great demonstration of the power of BI programs like Cognos. Report Authors dont need to fully understand the ways that two tables are joined... they simply pull out elements from each table and they work, as the relationships are already defined in the Framework.

Related

Table with variable number of rows in MS Office mail merge [duplicate]

I'm creating a compliance mailing for my organization, the mailing will include merge fields that identify the office location, physician, and SiteId. The mailing will also include a table of information that is dependent upon the particular SiteId.
I'd like to use the import table function of MS word and set up a query that references a merged field (SiteId) so that the inserted tables populate the appropriate data for the particular site. I'm unable to do this.
How can I set up this document so that I can import only records from my source (an ms access query) that match the SiteId merge field?
Word's mail merge does not support one-to-many relationships. There are ways to coerce it, but only one of them can yield a table as a result and over the years it has become less and less reliable as Microsoft has not regarded it as important enough to maintain...
What you need to do is set up a query that provides ONLY the information you want displayed in the table, plus the key (SiteId). It's best to sort it so that all the SiteId entries list together, and are in the order the data will come through in the mail merge data source.
On the Insert tab go to Text/Quick Parts/Insert Field and select the Database field from the list in the dialog box. Click "Insert Database" and follow the instructions in the dialog box to link in the data. Be sure to set the Query Options to filter on the first SiteId from the data source. When you "Insert Data" make sure to choose the option to "Insert as a field".
This inserts a DATABASE field in the document which you can see by toggling field codes (Alt+F9). The field code can be edited and what you need to do is substitute the literal SiteId value you entered for the query with its corresponding MergeField.
When you execute the merge to a new document that should generate a table for each data record corresponding to the SiteId for the record. But, as I said, Microsoft hasn't done a great job of maintaining this, so it may require quite a bit of tweaking and experimenting.
If the results are not satisfactory then you should give up the idea of mail merge and use automation code to generate and populate the documents.
You can find more (albeit somewhat out-dated) information on this topic at http://homepage.swissonline.ch/cindymeister/mergfaq1.htm

acumatica report designer union tables

Is there a way in Acumatica report designer to union two tables? I find that you have to link table to use them in reports. For example can you get data based on a date range from AP Invoice and AR Invoice without having a third table to link them together?
Thanks
A DAC created over a SQL VIEW with UNION ALL and added to ReportDesigner is likely the best approach, but perhaps a FULL JOIN will work for your purpose.
This link describes Full Join or Union All:
https://www.tutorialspoint.com/sql/sql-full-joins.htm
For your example in ReportDesigner, APInvoice could be FULL JOIN to ARInvoice on FinPeriod and Vendor/Customer on relationships tab, offer From/To date range parameters on parameters tab with defaults such as #monthStart and #monthEnd. Conditions tab could limit results to WHERE DocBal NotEqual 0. Display textboxes could use an IsNull such as:
=IsNull([APInvoice.DocBal],[ARInvoice.DocBal])

Spotfire control table values based on column value in another table

I need to control the data being shown on table Collections and Delivery based on what I click on Table A column value on Spotfire.
For example we have the three tables below:
When the user clicks on a column on Dashboard Table let's say BO: BN. On Delivery and Collections Table only BO row should only appear. How can you do this in Spotfire?
Note: The three tables have a relationship via Code and Branch column.
Additional data:
Collections and Deliveries table takes its data from DB using parameterized SQL Query.
There are three parameters that needs to be satisfied so that the query will work and data will be retrieved these are
StartDate
EndDate
Branch
I don't have a problem with the Date parameters but with the Branch see below SQL Query
The branch parameter value is controlled by specifying/entering a value on the input field on text area.
Deliveries and Collections table is configured to refer to this value to display the data.
The suggested solution worked great, but I have this extra dependency which makes it a bit more difficult to work out a solution. Do you have any ideas on how to go about this?
#dimas- One way to do this is creating detail visualization tables for Collections and Delivery from 'Dashboards table'.
Assuming that the three tables have relationship, please follow the below steps.
Step 1: Right click on Dashboards table and select Create Details visualizations -> Table. It prompts you to select a table, select 'Collections' tables.
Step 2: Repeat Step 1. But, this time select 'Delivery' table.
The Dashboards table now controls what data to show in Collections/Delivery tables based on the row selection.
Output:
Please ensure that you right click on the table and select Properties > Data > All data for Collections and Delivery table (screenshot below) if you want to show all rows if nothing is selected in Dashboards table.

Select clause editing in RedQueryBuilder

I'm looking into using RedQueryBuilder for a web-based query builder. I want my users to be able to specify what data they want to retrieve in the select clause, but the demo site
only shows selecting a single table, rendering all the columns of that table in the result. Does RedQueryBuilder support building out a more robust select clause, like specifying which specific columns to retrieve including those joined from other tables?
I'm afraid not. The project just concentrates on defining a query to return rows not what to show in those rows.
The onTableChange callback would feed you the list of tables in the expression so could go from that to a list of available columns...
Would you want/need to alter the SQL query generated or just the display of the results?
Personally I'd be interested in changing the demo into a more useful query too although the scope of that could be huge.

How does CRM 2011 auto-wire the StringMapBase table in for Option List picks in Advanced Finds?

The StringMapBase SQL table is the table that holds Option List values that have been added to an entity. When using an Advanced Find in CRM 2011, if you select a pick list column (Option List) value from an entity to be added to the resultset, the Advanced Find mechanism somehow auto-wires in the string value of the pick list from the StringMapBase table instead of showing the StringMapBase's Primary Key value that's actually stored on the record.
I'm in the process of creating SSRS reports that hinge on some Option List values:
// SQL psuedocode
Select...
...
Where Value = 'Some String Value of Interest'
However, I very much dislike the fact that, so far, it looks like I basically have to write in some ad-hoc SQL in order to get the applicable StringMapBase value. In order to do so, I have to hard-code some magic values, which I despise.
Does anyone know by what mechanism the CRM Advanced Find engine auto-wires these values in? Or does it simply do its own join to the StringMap system view or use a SPROC somewhere?
When you use the Filtered views (the only supported way to read data in your report) there will be an additional "logical" column for Bit, Picklist, and Lookup columns. For an attribute named "new_option" you should be able to add "name" to the end of the column name and query "new_optionname".
select new_option, -- Integer
new_optionname -- StringMap joins generated by Filtered Views
from Filterednew_test

Resources