0

I am new to Cognos and I know SQL but it seems I can’t figure out cognos logic for some basic stuff. It's been two days I am trying and I have been looking all over the internet without finding anything. Here’s the problem. I have a Dimension Product that has two dimensions under it: type of product and article (in this order, article is below type of product in terms of hierarchy). Let’s simplify and say I have this table:

Product line | Article   | Sales
-------------------------------
 Shoes       | Article1  | 1000
             | Article2  | 2000
             | Article3  | 10
             | Article4  | 20
             | Article5  | 30
 Bags        | Article6  | 100              
             | Article7  | 100
             | Article8  | 30
 Balls       | Article9  | 50
             | Article10 | 50

I want to display the sales per product line and per article for article1 and article2 and the sales per product line only for the rest. I want my final result to look like this:

Product line | Article   | Sales
-------------------------------
 Shoes       | Article1  | 1000
             | Article2  | 2000
             | Other     | 60
 Bags        | Other     | 330              
 Balls       | Other     | 100

I created an elementary data with the following expression “if [article-name] in (‘article1’,’article2’) then ([article-name]) else (‘other’) but it gives me this:

Product line | ArticleNEW| Sales
-------------------------------
 Shoes       | Article1  | 1000
             | Article2  | 2000
             | Other     | 10
             | Other     | 20
             | Other     | 30
 Bags        | Other     | 100              
             | Other     | 100
             | Other     | 30
 Balls       | Other     | 50
             | Other     | 50

I thought Cognos would group by automatically but it seems it does not when you create a new expression…. Please note that I have thousands of articles and I cannot create a data that would say “article3+article4+article5 etc.”. If anyone has an idea on this, it would be great! Thank you in advance!

Mara S
  • 13
  • 2
  • Check properties. What is the aggregation property of the new data item? Also, look at what the generated SQL is doing (examine the sum and group by) – VAI Jason Jan 16 '20 at 16:45
  • Hi Jason. Thanks a lot for your answer. There is no SQL generated, just a MDX code which I have trouble to understand. It is pretty short and simple though, there is no sum or group by, just a crossjoin between sales and article, and select statements. The aggregation property of the new data item is set on automatic. When I change to total or to "recap" (not sure what this is for), the report stays the same, it does not change anything. I am not very helpful sorry. Maybe someone has some document or link on custom groups in report studio (there are for analysis studio only) ? Thank you ! – Mara S Jan 17 '20 at 09:45
  • I tried grouping as well [link](https://ibb.co/GdgZh0m) but it is like it is doing nothing – Mara S Jan 17 '20 at 10:32
  • Also tried on query studio and there is something called custom groups so it works. Problem is my report is too big for query studio. When I do the exact same thing on workspace advanced, groups can only be created with measures, it seems. How strange. On report studio, functionality custom group does not exist. This tool is driving me crazy. – Mara S Jan 17 '20 at 10:58
  • 1
    Going back to VAI Jason's comment on the 16th, what is the aggregation set to on Sales and the other two columns. Also since you are getting MDX, can you please confirm the data source you are going against? – Daniel Wagemann Jan 20 '20 at 12:00
  • Hi Daniel, Thanks for your help. I only have the aggregation property for the new elementary data I created (if [article-name] in (‘article1’,’article2’) then ([article-name]) else (‘other’)), not for product line or article columns, neither for the sales. Data source is a cube, not directly a dabatase, maybe this is why? – Mara S Jan 21 '20 at 16:35

1 Answers1

0

I believe the issue is with the model. If you have access to Framework Manager and the project/metadata, this would change my answer

Try this method: 3 queries

1) Query 1 just have product line and article

2) Query 2 product line, article, sales

3) Next go to queries, then tool box, find the join.

Drag that over. There will be spots to add query 1 and query 2

In the middle is how you define the join

Connect the product line and article (there should be a button to add links so you should have 2 lines). This will be 1 to many (1.1 to 1.n). The first part represents the type of join, 1 being inner, 0 being outer. The second part is the relationship (either 1 or n for many).

We can group by query 1 and aggregate query 2 the way we want

Double click on query 3 and drag the data items (from query 1 and query 2)

Grab sales from query 2, and everything else from query 1

Now you should be able to set the aggregate property for Sales (either total or sum)

VAI Jason
  • 534
  • 4
  • 14
  • 1
    Hi Jason ! Thanks a lot for taking the time to explain. I created the two queries and the join [as can be seen in this pic](https://ibb.co/hWBn7Z9), configured the join as can be seen [here](https://ibb.co/MkbHHsc) and [here](https://ibb.co/gRCTjR7). I tried to add one simple [table](https://ibb.co/sJ0wQ8h) from the join but when I validate report I have this [error](https://ibb.co/gD89m9N), detailed [here](https://ibb.co/hsFtHSc). Probably my whole database or cognos config does not allow it? Good thing is that I have access to aggregate property for all columns thx to you :) Thanks again ! – Mara S Jan 21 '20 at 17:40
  • Hello, looking at the error, it appears cognos cannot find the data items from the query. Can you double check to make sure you are using the final query? You may have to remove or rebuild the list to test this – VAI Jason Feb 03 '20 at 14:45