Is it possible to create a custom equation in the group summary in COGNOS version 11 - cognos-11

I’ve created a report in COGNOS which groups all duplicate orders together which works well.
I’m trying to work out if there is a way to do a custom equation within the group summary to total the value for all entries within the group but then minus the first line within the group for a total.
The first entry within the group is the received order all others are extra orders received but are human errors. My hope is to have my report show a value for all the group total and then the group total minus the first value.
The total summary at the end of the report should then give me our final figures.
This way I can work out what we have paid for original orders and then when we have paid for extra unwanted orders. I’m hoping this makes sense.

Related

How to generate a distribution based bar chart on row_numbers

I have a SQL query that acts as a data source in my tableau desktop:
SELECT
row_number() over (order by sales) as rn,
article_number,
country,
SUM(sold_items) as si,
SUM(sales) as sales
FROM data.sales
WHERE sales.order_date between '2021-01-01' and '2021-12-31'
GROUP BY 2, 3
On tableau I dragged rn to column and sales to row to generate a bar chart. The following is the output:
I want to convert this into a 0-100% distribution chart so that I can get the following result:
How can I achieve this? Also, I want the user to filter by country level so even if the # of records increase or decrease, the distribution should always be consistent with the filtered data.
You can do this with nested table calcs.
For example, the following uses the Superstore sample data set, and then first computes a running total of SUM(Sales) per day, then converts that to a percent of total. Notice the edit table calc dialog box - applying two back to back calculations in this case.
The x-axis in this example is Order-Date, and in your question, the the x-axis is a percentage somehow - so its not exactly what you requested but still shows that table calcs are an easy way to do these types of operations.
Also, realize you can just connect to the sales table directly, the custom sql isn’t adding any value, and in fact can defeat query optimizations that Tableau normally makes.
The tableau help docs explains table calculations. Pay attention to the discussion on partitioning and addressing.

Trying to get the size (in %) of subcategories in a pivot

I am keeping track of my (stock) portfolio in Google Sheets, as follows:
category subcategory company amount
-------------------------------------------
health care diagnostics AA 100
health care diagnostics AB 50
materials mining BA 75
financials banks CA 30
financials insurers CB 35
financials banks CC 10
financials banks CD 40
financials hedge fund CE 5
health care equipment DA 50
But now I want to extract some statistics from this, and I'm using a Pivot. Specifically, I want to see:
the relative size of each category in the portfolio
the relative size of each subcategory in the portfolio
the relative size of each company in their subcategory
The first two I get done:
For instance, I can see that:
category financials has a relative size of 30% in the portfolio
subcategory diagnostics has a relative size of 37.97% in the portfolio
What is missing however, is the third column, see mockup below:
I can now see in the last column what the relative size of each company is in its subcategory:
Company CD is 50% of the subcategory banks
Company AB is 300.33% of the subcategory diagnostics
That last column however, is not calculated but added manually to show what output I am trying to get but am unable to.
Does anyone know how to have this last column as part of the Pivot?
Here is a link to the Google Sheet used: Pivot
Currently, there is no % by subtotal option in Google Sheets to show percentages against subtotals for the whole Pivot Table:
As a workaround, you can display the subtotal percentages by filtering the Pivot Table to display only one subcategory, for example:
Add Filter here and select subcategory:
Then select the desired field, for example, banks, and click OK.:
This should display the subtotal percentages like this:
Note: You can delete category field in Rows to make the Pivot Table cleaner.
You can also submit a feature idea request to Google Workspace, please see instructions on this site: Submit ideas for Google Workspace and Cloud Identity
So I found out there are two possible solution using calculated column and another using arrayformula.
Option 1: Use a duplicate pivot table. One issue of getPivotData function is that it will run in the table calculations stage so it will return empty result. So the solution was to have two clones of the pivot table. One will be used to retrieve the data and the other to retrieve the subtotal.
The formula to use would be
=amount/getpivotdata("amount",'Copy of Pivot'!$F$10, "category", category, "subcategory", subcategory)
Where amount, category, subcategory without the double quotes are values (references) filled by Google Sheets. While the double quoted ones are column names.
You also need to set summarize by to custom for it to work.
The only issue I found here is that I couldn't find a way to identify subtotal or total rows, they do have company value equal to the first record in the group. If anyone know how to know if I am rendering a subtotal, please let me know.
The second option is to use one pivot table only but reference original data.
=amount/SUM(QUERY($A$1:$D,"Select D Where A='"&category&"' AND B='"&subcategory&"'",false))
It still shares the same total rows though.
The last option will be the least robust. It would be using arrayformula but I don't have that ready at the moment. It is main issue is that changing the column orders or adding new columns will require to keep the position of the refenced columns and move the arrayformula columns. Not to mention, handling the empty cells in a category since data is grouped.

How to merge fields and vertical lines in details section

I am working on web based application using Visual Studio 2019 Preview with SAP Crystal Reports 2016 Support Pack 7.
The report consists of 20 columns in single row. There is a requirement to show two fix headings in details section.
Report Design:
What I want is to set the first heading in first row then list records from database then set other heading and print rest of the records by merging the fields and lines of first and second heading in details sections (similar to excel “Merge Cells Function”). Heading value is set in first column but since the width of first column is too short it is not visible and looks ugly.
Current Output:
Desired Output:
The number of records between first and second heading are not fixed and fetch from database.
In addition, since there are too many columns in single row not all columns are visible in printing. Could anyone advice how to fix them while printing?
Thanks
Group the report based on the logic of how you wish to separate the 2 groups of records.
Then, use a Group Header section to present the information you need at the top of each group.
note: if you are not familiar with Crystal, you Group by using
Insert, Group
or Report, Group Expert

PowerBI counts rows in non related table including filtering and non-matches

I have two tables in PowerBI and a slicer, presented below in an abstracted way.
I want to know the number of orders placed for a customer in a given date range. This data is a sample for illustration - there are actually around 10,000 Customers and 500,000 Orders and both tables have many other fields, Ids etc.
My challenge -
Whilst this is easy enough do by relating the tables and doing a count, the difficulty comes in when I still want to see customers with 0 orders and on top of that I want this to work within a date range. In other words, instead of the customers with no orders disappearing form the list, I want them to appear in the list, but with a 0 value, depending on the date range. It would also be good if this could act as a measure, so I can see the number of total customers that have not ordered on a month by month basis. I have tried outer joins, merge queries, cross joins and lookups and cant seem to crack it.
Example 1: If I set the order date slicer to be: 02/01/2017 to 01/01/2018 I want the following results
Example 2: If I set the order date slicer to be: 03/01/2017 to 06/01/2017 I want the following results
Any help appreciated!
Thanks
This is entirely possible with a Measure. When you're using the Order field to count the rows for each customer, you're essential doing a COUNTROWS() function.
With your relationship still active, we can Prefix this in a measure to check for the blanks, and in those cases, return 0. something like this would work
Measure = IF(ISBLANK(COUNTROWS(Orders)),0,COUNTROWS(Orders))
In this case, 'Orders' is the table containing the Order and Order Date fields

"Relationship may be needed" although relationship is set

I have two simple table in Excel 2010 - Products and Sales:
I then linked them into PowerPivot - and here created the relationship from Sales.ProductId to Products.Id - like this:
Now I'm trying to build a Pivot that for each productId in the Sales table also shows me the Category and the PurchasePrice from the ProductTable. However, here I'm stuck - because the relationship is somehow faulty. When configuring the Pivot, I get a message Relationship may be needed even if the relationship already exists. The resulting - wrong - pivot table looks like this:
though I'm actually trying to achieve this:
I know that I could create calculated columns in the Sales table of PowerPivot and pull all required data using the RELATED DAX function - but as the real world project requires a lot of joins and fields I'm hoping that there's a better solution than this workaround...
I uploaded the example file here.
Peter,
Your question was a bit more tricky than I first though and I spent quite some time digging around, but I think I found the solution after reading this article about making distinct count in related tables.
I have updated your source file (so that Sales table contains more than 1 sales per product) and uploaded it to my public Dropbox folder.
You can see that I created 4 new calculated measures to illustrate my solution and to make it a bit easier to understand (Excel 2010 terminology, in 2013 it's Calculated Field):
Sales Price Total
=SUM(Sales[SalesPrice])
Products Sold
=COUNT(Sales[ProductId])
Purchase Price per Item
=CALCULATE(SUM(Products[PurchasePrice]),Sales)
Purchase Price Total
=[Purchase Price per Item] * [Product Sold]
The key difference here is the formula for calculating purchase price per item. The reason why you should SUM the product purchase price within CALCULATE function is explained in great detail in the linked article (even though in a bit different context):
In this way, any filter active on Sales (the related table) propagates
to the lookup table.
There might be some other parts I missed, but I have tried this in couple other examples and it simply works as it should:

Resources