Report Studio 10.2.2: Showing distinct values in value prompt - cognos

Good afternoon,
I'm busy making reports in Cognos Report Studio 10.2.2 and as part of this, I need to group a number of accounts based on a group designation, so I can report on all records where the accounts from these groups are mentioned.
I've made a prompt page with a Value Prompt:
Query: Prompt_Group
Use Value: ID
Display Value: Group
Parameter: SelectedGroup
The query Prompt_Group contains:
Data Item: ID
Data Item: Group
Detail Filters: Group <> ''
To finish this, there's a query with the data to display, containing:
Detail Filters: AccountID IN ?SelectedGroup?
Now, I want to aggregate the Prompt_Group by Group, which is a text field, but I've ran into the following problems:
In the current set up, there's multiple occurrences of the same group, it'll show something like this:
GROUP: A
GROUP: A
GROUP: B
GROUP: B
GROUP: C
GROUP: C
GROUP: C
GROUP: D
If I change Use Value of the Value Prompt to Group, it shows the groups correctly (as distinct values), but my Detail Filter in the display query stops working, because it doesn't receive IDs.
I've tried all the Aggregate Functions on the Data Item: Group in the Prompt_Group query, but it will either show as the earlier list, or show as a list of 1's.
I'm at a loss here, how do I aggregate the ID by Group so that my prompt will only show the distinct groups, but receives -all- related IDs to the Group when I select it in the prompt?
Many thanks in advance!
Kind regards,
Martin

We'll call your output query Account and assume it has data items named AccountID and AccountGroup...
Set the Use Value to Group and update your detail filter to:
AccountGroup IN ?SelectedGroup?
If a grouping value (like AccountGroup) is not available in the query you are trying to filter:
Add a query.
Add a join to the new query.
Join Account to Prompt_Group on Account.AccountID = Prompt_Group.ID
Add all data items from Account to the new query.
Add Group from Prompt_Group to the new query.
Add a detail filter Group in ?SelectedGroup?
Select your visualization (list, etc.) and change the query it uses to the new query.

Related

NetSuite formula to show quantity ordred on first order

We have a saved search in place that displays date of first order and last order by customer & item within a given date range. For example - Looking at sales for May 2022 - today, it shows the item, the customer, the date they first ordered the item, and the date they last ordered the item.
I am now also trying to incorporate the quantity ordered on the first order.
crietera
results
I've tried the following, but keep getting an invalid expression. Can anyone advise on how I might be able to display the qty on the date of the first order?
MIN(CASE WHEN {custbody_reporting_ship_date} THEN {quantity} END)
and
CASE WHEN (MIN({custbody_reporting_ship_date})THEN {quantity} END)
I think this can't be achieved in saved search via simple formula. You may want to try below, what I will do is try to record the first and last order id in the customer record, then from customer saved search you can source from these order fields to the order details.
Create 2 custom entity fields applied to customer
first order id => Type:List/Record => List/Record:Transaction
last order id => Type:List/Record => List/Record:Transaction
Create 1 saved search to get the first order id per customer
Similar to the one that you created, the result field just need the customer internal id and min(document number) and filter need to add customer.internal id
Create 1 saved search to get the last order id per customer
Similar to the one that you created, the result field just need the customer internal id and max(document number) and filter need to add customer.internal id
Create 2 scheduled workflows, to update the first order id and last order id fields in respective customer record.
Create your first and last order customer Saved Searches using the 2 custom fields to source for the order details.
Not sure if this help.

drop down list suggestions limited to particular values

I have a list of group leaders and each group leader has his own team, when a group leader clicks on his name, it leads him to his employees, I wanna make a drop down list so he can select the employee he wants but i dont want the drop down list to show all the employees from all the teams, i only want it to show the employees of that particular group leader.
there is no data limiting possible so i wonder how it is possible to do it, or if it is even possible.
Thank you in advance.
Create a reference data table with one column - 'leader'.
Create a reference data table with two columns - 'leader' and 'employees'.
Create a Document Property ('ldr') based on distinct column values from the 1st data table - which will allow leaders to select their own name.
The value of 'ldr' will now be used to filter the data in the 2nd data table, by going to Data Canvas, adding a 'Filter' transformatopm and using a custom expression like this:
case when DocumentProperty('ldr') = '' then true
when DocumentProperty('ldr') != '' and DocumentProperty('ldr') = [leader] then true
else false end
So now your 2nd data table should have only the employees of the selected leader.
Create a new drop down Document Property ('emp') based on distinct values in the employee column of the 2nd data table.
These two document properties created in the previous steps are just filters which have the appropriate employee values but are not linked to any visualization yet.
So to link the filters to the visualizations, go to Visualization properties -> Data -> Limit Data using expression -> Use an expression like:
[employees] = DocumentProperty('emp')

Filter the data in one query based on the result from another query in Cognos

I need to use a column data obtained in a query in Q1 as a filter in Q2. Is there a way? Can anyone please suggest? I'm a beginner.
PS: Need to pull the report based on the country.
I have 3 columns in Q1 ---> User Name, User ID, User email
3 columns in Q2--> User ID, user location and user country
A join condition between Q1.userID and Q2.userID works.
but I need to create a report that pulls the users details based on the country I select.
It would be best to do this via a proper model instead of modelling in the report. That being said, in a pinch, you could set the allow cross join query hint on both queries and create a filter similar to:
[Query1].[UserID]=[Query2].[UserID] and [Query2].[Country]=?p_Country?

Get index list for a table in Sybase

This link contains the answer to the question, but it is not completed.
A Sybase DBMS has a notion of catalogs and schemas. So, how do I write a query to retrieve list of indexes for a table inside schema that is inside catalog?
[EDIT]
Consider following scenario:
USE test
GO
CREATE TABLE dbo.test_table(<field_list>)
GO
CREATE TABLE foo.test_table(<field_list>)
GO
CREATE INDEX test_index ON test_table(<index_field_list>)
GO
As you can see there are 2 test_table tables created: one in the schema called dbo and one in the schema called foo. And so now my question would be - how do I write a query that properly check for existence of the index on the table test_table in the schema foo? Because the link I referenced does not differentiate between those 2 tables and therefore will fail in this case. I very much prefer to filter schema and table names rather than using schemaName.tableName format. I hope you get an idea. If not please let me know and I will try to explain with even further details.
[/EDIT]
If you're signed into the test database as user foo, the create index command will be applied against the foo.test_table table (precedence is given to objects you own).
If you're signed into the test database as anyone other than foo, and assuming you have permissions to create an index, the create index command will be applied against the dbo.test_table table (precedence goes to objects owner by dbo if you don't own an object of the given name and you have not provided an explicit owner).
If you know you're going to have multiple tables with the same name but different owners, it's a bit more 'clean' to get in a habit of providing explicit owner names (and you're less likely to issue a command against the 'wrong' table).
As for how to check for the existence of an index ... in a nutshell:
sysusers contains db user names and ids (name, uid)
sysobjects contains object names, object types, object ids and owner ids (name, type, id, uid)
sysindexes contains index names, object ids, index ids, and a denormalized list of columns that make up the index (name, id, indid, keys1/keys2)
syscolumns contains column names for tables/procs/views, object ids, column ids (name, id, colid)
Sample joins (using old style join clauses):
select ....
from sysusers u,
sysobjects o,
sysindexes i
where u.name = '<user_name>'
and o.name = '<table_name>'
and o.type = 'T' -- T=table, P=procedure, V=view
and i.name = '<index_name>'
and o.uid = u.uid
and o.id = i.id
The join from sysindexes.keys1/keys2 to syscolumns.colid is a bit convoluted as you need to figure out how you wish to parse the keys1/keys2 columns to obtain individual syscolumns.colid values.
Again, I'd suggest you take a look at the code for the sp_helpindex stored proc as it references all of the appropriate system (aka catalog) tables and includes examples of the necessary join clauses:
exec sybsystemprocs..sp_helptext sp_helpindex,null,null,'showsql'
go

Powerpivot duplicating values

I have two tables:
First table contains sales pipeline information for accounts (contains pipeline ID, accountID, and pipeline value). Each account IDs have multiple pipeline ID
Second table includes the number of employees per account.
I included these tables to powerpivot, and I created relationship based on account ID.
I would like to create pivot that tells by Number of employees & Pipeline value by account ID and PipeID.
However, when implemented, it repeates all pipeID for each account. Even those pipeIDs which are not related to the account.
http://i.stack.imgur.com/WY1Ga.png
Could someone point me to a right direction to how I tweak the pivot to show only relevant pipeID?
I would appreciate any help you could provide...
thank you!
The numbers repeat in your pivot table because Number of Employees is not related to Pipeline ID. This is Excel's default reaction to missing relationships. To get rid of the repeating numbers and keep this pivot table as is you need to find a way to relate number of employees to a pipeline ID.
If I were modeling this, I would have a separate table that is just distinct Account IDs, to make it it's own dimension. Then have your two tables you mentioned in the question.
If you were simply writing a query against this data, how you would connect pipeline ID to number of employees? To which pipeline should an employee be attached ? If there is a way to do this manually/in a query, adjust your two tables to both include the fields on which you would join. I don't think you would be able to relate Number of Employees to Pipeline ID, so I would remove Pipeline ID from the pivot table. Then the numbers should be correct. You would want to create another pivot to show pipeline by pipeline ID per account.

Resources