COGNOS make the join conditional between query subjects - cognos

In COGNOS, when I create a 1...1 relationship between 2 query subjects A and B, is the relationship always in effect? Or is there a way to say only force the relationship when I am querying A, but when I query B, give me all records from B and ignore A.
This is important because for me, B is a prompt query subject based on a lookup table. so let us say A is a list of all customers and B is a lookup table for Status(Active/Inactive).
When I query B, I just want to see Active/Inactive as prompt values. I select Active and it should bring me only records from A with Active Status.
Is this possilbe?

Cognos uses minimized SQL as default. You can read on it in here:
Cognos - What Is Minimized SQL?
What it basically means is that Cognos picks only the required fields in the SELECT statement.
So, if you picked for prompt values fields from table B, it will only use (for Prompt page only) table B.
When you execute the report assuming you have values from both table A and B, it will do the join

Related

How to identify all columns that have different values in a Spark self-join

I have a Databricks delta table of financial transactions that is essentially a running log of all changes that ever took place on each record. Each record is uniquely identified by 3 keys. So given that uniqueness, each record can have multiple instances in this table. Each representing a historical entry of a change(across one or more columns of that record) Now if I wanted to find out cases where a specific column value changed I can easily achieve that by doing something like this -->
SELECT t1.Key1, t1.Key2, t1.Key3, t1.Col12 as "Before", t2.Col12 as "After"
from table1 t1 inner join table t2 on t1.Key1= t2.Key1 and t1.Key2 = t2.Key2
and t1.Key3 = t2.Key3 where t1.Col12 != t2.Col12
However, these tables have a large amount of columns. What I'm trying to achieve is a way to identify any columns that changed in a self-join like this. Essentially a list of all columns that changed. I don't care about the actual value that changed. Just a list of column names that changed across all records. Doesn't even have to be per row. But the 3 keys will always be excluded, since they uniquely define a record.
Essentially I'm trying to find any columns that are susceptible to change. So that I can focus on them dedicatedly for some other purpose.
Any suggestions would be really appreciated.
Databricks has change data feed (CDF / CDC) functionality that can simplify these type of use cases. https://docs.databricks.com/delta/delta-change-data-feed.html

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')

Syntax for DISTINCT query on one column in MS Query

I have an Excel spreadsheet which I use as a relational database for my milk round. I query this database using MS Query in Excel (Mac 2011 Version) to generate my delivery routes. One of the columns is the customer address and I'd like to have this shown once per order i.e. have a distinct query for just this column while displaying multiple other rows. It's purely for cosmetic purposes to make the spreadsheet less cluttered.
The main spreadsheet I use as my database has column headings which I have screenshotted, complete with some sample data:
From this main spreadsheet I use MS Query to generate my delivery route which looks like this:
As you can see there is a lot of repeated data in the route generated from the query. What I'd like to do is have just one instance of the address per customer's order, it would help with the legibility of the route when opened in an iPad. I hide other columns that aren't really necessary to help in that regard.
*EDIT
From isolated's comments below, here's a screenshot of ideally how the data returned from the query should look:
I've manually deleted the repeated info in the name & address column to achieve the desired result. I've also hidden some columns that aren't really necessary and I use some conditional formatting rules to help distinguish each customer's order.
EDIT*
I have tried using a group by clause and the following window function but can't get it to work:
SELECT *
FROM (
SELECT “All Orders”.”Route ID”,
“All Orders”.Name,
“All Orders”.Address
ROW_NUMBER() OVER(PARTITION BY “All Orders”.Address
ORDER BY “All Orders”.Address DESC) AS row_number
FROM “All Orders”
) AS rows
WHERE row_number = 1;
Whenever I try to run the query I get an error message regarding syntax. Hopefully someone can tell me where I'm going wrong!
I don't know MS Sql at all, but you could do something with a formula in excel. If you don't like this solution, simply put a comment below that you would still like a sql route and I can get you a query to try to adapt to ms sql.
Create another column and call it address2 (or several more columns if your address field is multiple columns).
Then use this/these formula and adjust as needed:
Column F (address2): =IF(A2=A1,"",C2)
Column G (town2): =IF(A2=A1,"",D2)
You can then hide columns C and D.
=============
U P D A T E
Here's a method that works in many dbms such as postgres, but I don't know how to adapt [rank() over (partition by...] to excel sql.
select account,
cust_name,
item,
case
when prod_rank = 1 then address
else ''
end address
from (
select
account,
cust_name,
item,
address,
rank() over (partition by account order by item) as prod_rank
from table1
)z
order by account, item
I tried a few variations in excel sql and finally got this one to work.
select a.Account,
a.Name,
a.Product,
Iif(a.product = b.min_item,a.address,'') as [address]
FROM table1 as a
,(
select
z.Account,
min(z.Product) as min_item
FROM table1 as z
group by z.Account ) as b
where b.account = a.Account
order by a.account, a.product

How to make a dynamic list from a multi variable table with boolean values?

Please help, very stumped with this one.
I've been provided with a matrix table as seen in image attached. I have a list of users, as well as the courses that they need to be enrolled in.
I'm trying to create a list that will repeat the usernames for every course that they're enrolled in (in column A, and then a list of the courses they are enrolled in (column B)
So far, I've been able to create such a list by creating a pivot table from this data, double clicking the grand total, and sorting the results, but this is a very manual process, and it needs to be replicated by others.
Is that possible?
Google Drive link: https://drive.google.com/file/d/1zXsWZCguia-SLaYAP-81kMX819879zzX/view?usp=sharing
This is just something to get you started:
Convert your data to an Excel table
Steps:
In Excel:
Select the data range (starting from row 3)
Press Ctrl + T
Select Data | Get data from table
Transform your data in Power Query
In Power Query:
Select the columns headers (from FirstName to User)
Right click them
Select UnPivot other columns

Add column that does not refresh in powerquery / excel

I try to combine a power query generated view with a column for user input during a review session.
I would like to prevent this column from changing upon data refresh.
A | B
--------------
Stats | Review
Long | good
Short | bad
A can update. B is unknown at query time and therefore created with empty values. It is populated by the user. I want to update A, but don't remove the values in B.
I tried to add column B in excel instead of power query, after generating the query to an Excel table. It kind of works as the values stay in the column. However, the order is messed up when I refresh.
Ultimately I think this might be possible with power query when generating the table.
Can this command be modified to get the desired behavior on the column?
Table.AddColumn(#"A", "B", each null)
Sorry for the bad example, its kind of hard to show proper excel/powerquery 'code'.

Resources