Continuous dates in Cognos - cognos

I need some suggestion to generate a continuous dates in between a specified selected date range in Cognos. I can create a separate Data item for this but I don't know what to do after that. Looking for a quick help

You need to get your list from a Calendar table which joins to your query in framework, or create a seperate Query Subject that pulls in the date list from a Calendar table or custom SQL. For more info on generating a range of dates using SQL see this: Generate a range of dates using SQL
Once you have a query subject with a date field that contains 1 record per date you want, create a dummy field to use to join it to your main query. A simple data item named 'join1' with the value '1' will work. Create the same field in your main query. Join the two Query Subjects together on the 'join1' field. This is going to result in your data getting multiplied out into the date range. IE. If you have a main query that lists 1 record per employee, the result after the join will be 1 record per employee per date in your date range.

Related

How can I transpose and summarize data appropriately in PowerQuery?

I'm working on achieving the following data transformation/wrangling within Power Query but can't seem to get there on my own. i have read a lof of different questions and answers on the forum but it seems just a bit beyond my grasp.
I have a table which has the ticker of a specific currency in the first column.
There is a second column with the date and time when a certain event, related to that specific currency, happens. This second column is basically the different 5-minute intervals which exist on any given day.
Finally there is a third column which describes the magnitude of the event.
The table therefore looks like this
What I would like to do in power Query is transpose the uniques name of the currencies as the first row of a new table. The first column of this table would be the largest time interval for any given currency. In this case, as you can see in the data I am attaching, the largest timeseries would be that of the currency ETH. Using the longest calendar as our first column I would then like to place the values described in item 3 above as rows in the new table.
The new layout would look like this
My steps to transform the raw data in the first table are detailed in this image. Basically just expanding a JSON file and getting all the data I need into that first format which I described previously.
What I then do is:
Pivot using the first column
Transpose
That gives me a whole bunch of new columns. Way more than I want. Any idea what I can do differently?
In powerquery,
click select pair column
Transform .. pivot column .. values column: basis advanced options: do not aggregate
code:
#"Pivoted Column6" = Table.Pivot(YourPriorStepName, List.Distinct(Source[pair]), "pair", "basis", List.Sum)
output:

Count of KPI from different tables based on date

I have the following 4 tables and i want to show the count of ID's for each KPI's for each Caseload (1,2,3,4 etc ) something like in the second picture.
I am not sure what is the correct method but i've created a date table and use as slicer because one iD might be in a all 4 table but the KPI*Date might be different.
Any ideeas how to calculate this ?

How to invert a merge query in power query

I have a single column table of customer account numbers and a main table containing 400,000 records pulling from an access database. I want to remove all records from the table where the customer account number can be found in the single column table.
The merge query capability in power query allows me to return only the records where there is a match on the customer list (in addition to a variety of other variations on this theme) but I would like to know whether there is a way to invert this so that I return all records where the customer number does not appear in this list.
I have achieved this already by using the List.Contains function and adding a custom column to identify the rows to exclude and then filtering them out, but I think this is severely impacting the performance of my workbook. Refreshing the table that initially has 400,000 rows prior to this series of transformations takes a very long time, and all queries that depend on this table then also take a long time to refresh.
Thank you
If you do a Left Anti Join of your table with a single column, this will give you your table filtered to only have the rows which do not match to the single column.

Performance tuning in Cognos Report Studio

Working in Cognos Report Studio 10.2.1. I have two query items. First query item is the base table which results in some million records. Second query item is coming from a different table. I need to LEFT OUTER JOIN the first query item with other. In the third query item post the join, I am filtering on a date column which is in formatYYYYMM to give me records falling under 201406 i.e the current Month and Year. This is the common column in both the table apart from AcctNo which is used to join both the tables. The problem is, when I try to view Tabular datathe report takes forever to run. After waiting patiently for 30 mins, I just have to cancel the report. When I add the same filter criteria to the 1st query item on the date column and then view the third query item, it gives me the output. But in the long run, I have to join multiple tables with this base table and in one of the table the filter criteria needs to give output for two months. I am converting a SAS code to Cognos, In SAS code, there is no filter on the base table and even then the join query takes few seconds to run.
My question is: Is there any way to improve the performance of the query so that it runs and more importantly runs in less time? Pl note: Modelling my query in FM is not an option in this case.
I was able to get this resolved myself after many trial and errors.
What I did is created a copy of 1st Query item, and filtered 1st query item with current month and year and the for the copy of 1st query item added a filter for two months. That way I was able to run my query and get the desired results.
Though this is a rare case scenario, hope it helps someone else.

Cognos-how to create a end report for a calendar with aggregation

I would like to create an end report, which shows a calendar(month) with aggregation for the specified data.
I am working on cognos 8.4, I have a requirement where I have to show the statistics of the month in a calendar form. The report should be dynamic and it should display the details of the particular month.
Any help or advice is highly appreciated.
Have you tried creating a crosstab? I would create an SQL view of your data to get something like this:
select amount, DayNumber, DayofWeek, MonthName, MonthNumber, YearNumber, Weeknumber
from your_view
Within Report Studio filter on YearNumber and MonthName (ordering by Monthnumber). Then create a crosstab where columns would be DayofWeek and rows would be Weeknumber. Inside the crosstab drag the amount field.
Remember Cognos auto-sumarize everything by default unless you override that behavior.
One thing I cannot think to figure it out is how to display the DayOfMonth within the crosstab. That one is tricky since the data is string and it is not groupable in any calculation (MAX, SUM, AVG, etc). If you can find a solution for that, please let me know. Cheers.
You can use a repeater table, and the table will use a query which gives you the dates, you can apply the filter in that query for the user-selected month. After you have that part working, you can pull a list into the repeater table and then use master-detail relationship from the date query to the list query, then you can design your list inside the table.

Resources