Converting Cognos reports to SSRS , what does XSUM command does? - sql

We are in process of converting cognos reports to ssrs reports . i have a query which i got it from the cognos report and it is written in pervasive sql i am not sure about the language. I am able to interpret most of the query but i am stuck with one command XSUM. It has a syntax as
XSUM(col21 at col3 col7 col5 col5 for col3 col7) as col22 where col21,col3,col5, and col7 are columns from the table.
Can any one help me in understanding what the command XSUM does and what is the equivalent of it in T-sql please.
Thanks.

The X stands for extended.
Your report is probably doing some arithmetic on the application outside of the database that is generating these xsums and xmins.

The XSUM is just as Stephen has highlighted. It means calculations are being performed within the report itself. Is your report doing any roll ups or aggs across queries or subtotals in the crosstab itself or are you joining subqueries within a report. Once you have subqueries and tie them together, the arithmetic has to be performed on the application servers. Think of it as a two tier approach -> gather the data from the database that meets the criteria of the filters -> then aggregate the data on the application server before firing off to the UI.

You may want to looking at the native sql and cognos sql probably one of them may not have the Xsum.
Apart from this, will there be a semantic layer in SSRS where you have to create something similar to a package. If thats the case , would be better to recreate the report in SSRS.
Thanks
PR

Related

From whole number to percentage in SQL extract in Power BI

I have to extract data in Power BI using a SQL statement. It is a simple select ... from ... group by ... and then I retrieve for example the value 925. And here is my request. What I want is to retrieve 9,25 directly with the SQL statement but I can't find how. When I use a Cast or Convert I always retrieve 9 without the decimals. And if I use the Data Type "percentage" from the Query Editor it will display 925000 so this is not the solution.
Any idea ?
For a simple query pattern like that, I would not bother with a custom SQL statement. Just connect to the source table/view using the Navigation UI, then add a Group By step in the Query Editor window.
You will have less code to maintain (actually none), and the underlying datatypes will be passed through automatically.

Conditional Column POLL: SQL vs Power Query vs DAX

Need to add a multi conditional (approx 12) column to an Excel file and was wondering what was more efficient: SQL (CASE), M/PowerQuery (if-then-else), or DAX (SWITCH).
What are you experiences?
TIA,
Danny
I would use the Conditional Column feature in the Query Editor ("M/PowerQuery") for this requirement. It's the only option where you won't need to write any code at all, even for requirements like "does not contain" that are quite complex to code in your alternatives.
I tell my data analyst clients not to bother learning SQL any more - the Power BI Query Editor / Power Query for Excel is so much more productive.

Jasper Reports: How to use a SQL result in the title block and use it for subreporting?

In Jasper Reports, how do I use a SQL result in the title block and use it for subreporting?
I have previously successfully used a SQL result in the title block when there is only one result, and am not depending on it to spawn multiple subreport sections. In this instance I would like to do both use the SQL result and have multiple subreports.
My current simplified query (Oracle SQL)
SELECT DISTINCT
LOC."NAME" AS LOCATION,
coalesce($P{input_date},($P!{default_date})) as ACTUAL_TIME
FROM
"CF"."LOCATION" LOC
WHERE
(LOWER(LOC."NAME") LIKE '%'||LOWER($P{input_location})||'%')
There are three locations, and each generates two subreports grouped by location.
default_date is defined as the result of an oracle function
"SELECT START_TIME FROM CF.LAST_OPERATIONAL_DAY"
Operational days do not run 24 hours, from midnight to midnight.
1) I have been using this default_date technique with most of the reports, hopefully easing maintainability. However, evaluating the actual-time 3 times could cause the reports to run for different days if run at the wrong moment.
2) If I put $F{ACTUAL_TIME} in my Title, it shows as null. (In our simpler reports, the primary query returns one value, and this field is usable in the Title.)
3) My searching has lead me to believe that subqueries are not permitted without a list, table, or subreport.
There is the possibility of reimplementing the Oracle function in Java to set a new parameter. If input_date is null, use the new variable, but I fear the maintenance headache as we proceed.
There is the possibility of creating another layer of sub-subreport. That would make the few most complicated reports more complicated.
Is there a simpler option? Can queries be done at the parameter level? In the header? Is there some setting I'm missing?
---We are using Jasper Server 6.1.1 and Jaspersoft Studio 6.1.1 and have the flexibility to upgrade if necessary. The database is Oracle 12c.

Crystal Reports formula field IF LIKE

I'm a little confused with Crystal Reports [LIKE] pattern operator, compared to SQL's [IN] operator.
I have inherited maintenance of an old report that uses FORMULA FIELDS to qualify the data used in SELECTION FORMULAS > RECORD SELECTION.
One of the FORMULA FIELDS uses [LIKE] to limit the records returned.
EXAMPLE IN CRYSTAL:
IF {table.column} LIKE ["A","B","C"]
COMPARED TO SQL:
SELECT * FROM table WHERE col1 IN ("A","B","C")
I can't find documentation that uses LIKE in this way.
Since I can't find supporting documentation for LIKE I question if this is the "best practice" for filtering content. Is there a better way?
Thanks,
-Allen
It is the correct way to use in crystal.... it will pick the values that satisfies the like operator... also you mentioned it in record selection formula so it will be directly included in where clause of the query generated in crystal
Edit----------------------------------------------------------------------------------------------
Use below link to know the documentation of the crystal reports.
Link
I have pasted for Like operator but if you want to see documentation for formulas or build different formulas you can use above link.

MDX query issue

In analysis services, I have cube that is based on hospitalization data. For each hospitalization there are potentially 9 icd codes and these are each stored in their own field in the view on which the cube is based. These are stored in a child table in the relational database on which the SSAS database is based.
I would like to query the cube to return all rows that have a certain ICD code in any one or more of the 9 icd code fields. It seems as if it should be simple to have this sort of "OR" in the WHERE or the Filter clause, but I'm not finding the correct method.
Thanks in advance,
Jeremy Schrader
As far as i understand, you are an SQL guy and new to MDX, so that's why you have difficulties for the query.
it would be better if you tell us what are the measures you want to select with ICD codes but i am going to try to show you an mdx query sample as simple as possible. Your query should like below;
select {Measure1,Measure2,...} on columns
ICDCodeDimension.Children on rows
//{ICDCodeDimension.ICDCode1,ICDCodeDimension.ICDCode5,...} on rows
from Cube
MDX is highly advanced query language and there are many more concept you should know/learn to use it effectively.
Hope this help.
I am guessing that you'd have a dimension called [ICD Codes] with a single level called [Codes] and 9 members called [Code A] and [Code B] or whatever. Perhaps even a member for [No code] too?
In that case your query would be able to tell you the total number of hospitalisation cases for each code, for a certain time period, across all hospitals:
SELECT {[ICD Codes].[Codes].members} ON ROWS,
{[Measures].[Number of Cases]} ON COLUMNS
FROM [CubeName]
WHERE ([Time].[2010].[Quarter 1])
Thanks for both of your feedback. After I researched further (particularly an article here: http://sqlblog.com/blogs/mosha/default.aspx that uses the SUBCUBE method to give some "OR" functionality but with very poor performance) I realized that the OR construct that I was looking for requires record-level information and so doesn't work after the aggregation that SSAS performs. Thus, I need to create a field on the fact table that has the result of the SQL "OR" statement that I need.
In this case I will just create a flag for any record that has a certain range of ICD codes in any of the 9 ICD code fields. Then, I'll create a measure that gives a count of these. Luckily, the requirements of my app are that only a limited number of diagnoses need to be looked at in this way(i.e. any hospitalization that is diabetes-related,tobacco-related,etc.). I'm still curious how one would approach this if you needed to allow the user to choose any ICD code. My understanding at this point is that you would then need to revert back to plain SQL.
Jeremy