Linking multiple columns of one table to a single column in another table - Qlik Sense - qliksense

This is a qlik sense question.
I have the below table (project_task) for the tasks and subtasks.
The tree looks something like this (X,Y,Z,A,D are root nodes):
I have a table(task_tree_format) like this in database, which depicts the project tasks in depth format:
I want to place the name1, name2 and name 3 in pivot table so that it appears in hierarchical format(with expand and collapse buttons) in my Qlik Sense sheet.
My requirement is -
When task 'B' (NAME2 column) is selected in pivot table, it should perform the operation based on the same 'Task Name' in project_task table.
Eg.. If I select Task 'B' in pivot table, it should trigger the 'Task Name' B in project_task table.
In short, I want to associate NAME1, NAME2 and NAME3 columns with the 'Task Name' column in project_task.
I request your help on how to proceed with this in the load data editor.
Appreciate your help regarding this.
Thanks!

A Pivot table cannot be used to represent a tree of unlimited depth. You are trying to use the wrong tool. What you need is a recursive algorithm that will read the table and spit out to the tree using the desired indentation and aggregation on another sheet.
That said, you would be better off using MS project or any proper project management tool rather than reinventing the wheel.

Related

How to find the average progress (per level) in a hierarchical tasks tree with PostgreSQL?

I´m trying to determine the average progress of each task group in a tasks tree. The problem is that only the leaf nodes (which are in a diferent table ‒ a child table ‒) actually have the progress field.
I have a Tasks (parent) table and an Activities (child) table. Both of them share IDs. I should point out that I´m using the ltree extension in my DB.
I´m trying to make a view showing the entire tree and a column with the average progress per node level. I have to start the calculations from the inner-most level and build my way up in the tree structure, but I can´t seem to get it right.
I´ve tried to approach this using recursive CTEs and window functions to no avail. Postgres doesn´t allow to use aggregate functions in the recursive term of a recursive cte, so that didn´t work.
These are my tables (simplified):
tasks:
=======
id -- SERIAL
parent_id -- INTEGER
project_id -- INTEGER
name -- VARCHAR
task_group -- BOOL
path -- LTREE
activities:
===========
id -- INTEGER
progress -- INTEGER
EDIT
This is a screenshot of the view as of right now. I´m able to get the average progress of all leaf nodes, but that´s not exactly what I need. The average progress should be calculated for each level in the tree, and then build it´s way up in the node hierarchy.
Any insight on this will be much appreciated. Thanks in advance.

Limit table in spotfire based on marked rows in another table

I have 2 tables in my visualization. One is a list of tasks to be done, and one is a list of repairs that have been done at each location. I want to be able to filter the repairs table by the locations of the highlighted tasks. Ergo if you marked a task that takes place at location 1, the second table would filter to only show repairs for location 1. Is that something that's doable?
Thanks in advance
This is pretty easy to do. You need to create a relation on the Location column between your two tables (Data table properties, Relations tab). Then create a details visualization (right click on "parent" table and select details visualization). Because you have created the relation already, it will ask you which table you want to be the "child". After selecting which table, you will be able to click on the parent, and it will filter in the child table. Also note, using the right click menu is engaging the data limiting with marking, which you will be able to see in the properties dialog, data menu. You don't have to use the right click menu to setup details visualizations. It's just easy.
I've written a lot about how to use relations and column matches. See links below. Relations integrate filtering, which is what you want. Column matches integrate marking.
https://www.bigmountainanalytics.com/apply-relations-and-column-matches-in-spotfire/
https://www.bigmountainanalytics.com/how-to-use-relations-in-spotfire/
https://www.bigmountainanalytics.com/how-to-use-column-matches-in-spotfire/

SSRS subquery based on other query

I'd like to make an overview of projects.
This contains some fixed info; table projects joined with some other tables.
Now the report needs to have some subqueries: how many sales per salesman, how many is in transit, inventory, ... and so on.
I have a tablix with grouping on project (as to create an excel with one worksheet per projet).
How would I go about executing a new subquery per project (f.e. select owner, sum(totalprice) from opportunities where project=xxx group by owner)
I know I could achieve this with subreports; but as I will have about 10 subreports, I was hoping I could solve this with extra datasets and some filtering (and thus keep all logic in one file).
What's the best way to achieve this?
I would create a dataset with this query:
select owner, project, sum(totalprice) as totalprice from opportunities group by owner, project
Next, in your tablix where you want to display owner and totalprice info, you will have an expression like this:
=LOOKUP(Fields!<FirstDataSetProjectFieldName>.Value, Fields!project.Value, Fields!owner.Value, "<NewDatasetName>")
The above code will send the value of the project you are searching for, match it with a the same field in your new dataset, then return the requested value from the new dataset. You can obviously do this for totalprice as well.
Check out the documentation for LOOKUP to get a better handle on it but I think this is the solution you are looking for.

Document Generation Order

I would like to report an UI diagram to a Word file.
I therefore create a template to extract the controls and their notes to a table.
The table, by default, is sorted by the aleph beta order of their names.
Is there a way to order the tabe by the order of the controls on the diagram?
The default options are to order by Tree order, Name, Modified date or Created date, so no diagram position.
What I would do is probably create an SQL fragment and order them in the query. It's a tad complicated, but doable if you know your way around the EA database structure.

Reporting Services and Dynamic Fields

I'm new to reporting services so this question might be insane. I am looking for a way to create an empty 'template' report (that is basically a form letter) rather than having to create one for every client in our system. Part of this form letter is a section that has any number of 25 specific fields. The section is arranged as such:
Name: Jesse James
Date of Birth: 1/1/1800
Address: 123 Blah Blah Street
Anywhere, USA 12345
Another Field: Data
Another Field2: More Data
Those (and any of the other fields the client specifies) could be arranged in any order and the label on the left could be whatever the client decides (example: 'DOB' instead of 'Date of Birth'). IDEALLY, I'd like to be able to have a web interface where you can click on the fields you want, specify the order in which they'll appear, and specify what the custom label is. I figured out a way to specify the labels and order them (and load them 'dynamically' in the report) but I wanted to take it one step further if I could and allow dynamic field (right side) selection and ordering. The catch is, I want to do this without using dynamic SQL. I went down the path of having a configuration table that contained an ordinal, custom label text, and the actual column name and attempting to join that table with the table that actually contains the data via information_schema.columns. Maybe querying ALL of the potential fields and having an INNER JOIN do my filtering (if there's a match from the 'configuration' table, etc). That doesn't work like I thought it would :) I guess I was thinking I could simulate the functionality of a dataset (it having the value and field name baked in to the object). I realize that this isn't the optimal tool to be attempting such a feat, it's just what I'm forced to work with.
The configuration table would hold the configuration for many customers/reports and I would be filtering by a customer ID. The config table would look somthing like this:
CustID LabelText ColumnName Ordinal
1 First Name FName 1
1 Last Name LName 2
1 Date of Birth DOBirth 3
2 Client ID ClientID 1
2 Last Name LName 2
2 Address 1 Address1 3
2 Address 2 Address2 4
All that to say:
Is there a way to pull off the above mentioned query?
Am I being too picky about not using dynamic SQL as the section in question will only be pulling back one row? However, there are hundreds of clients running this report (letter) two or three times a day.
Also, keep in mind I am not trying to dynamically create text boxes on the report. I will either just concatenate the fields into a single string and dump that into a text box or I'll have multiple reports each with a set number of text boxes expecting a generic field name ("field1",etc). The more I type, the crazier this sounds...
If there isn't a way to do this I'll likely finagle something in custom code; but my OCD side wants to believe there is SQL beyond my current powers that can do this in a slicker way.
Not sure why you need this all returned in one row: it seems like SSRS would want this normalized further: return a row for every row in the configuration table for the current report. If you really need to concatenate then do that in Embedded code in the report, or consider just putting a table in the form letter. The query below makes some assumptions about your configuration table. Does it only hold the cofiguration for the current report, or does it hold the config for many customers/reports at once? Also you didn't give much info about how you'll filter to the appropriate record, so I just used a customer ID.
SELECT
config.ordinal,
config.LabelText,
CASE config.ColumnName
WHEN 'FName' THEN DataRecord.FirstName
WHEN 'LName' THEN DataRecord.LastName
WHEN 'ClientID' THEN DataRecord.ClientID
WHEN 'DOBirth' THEN DataRecord.DOB
WHEN 'Address' THEN DataRecord.Address
WHEN 'Field' THEN DataRecord.Field
WHEN 'Field2' THEN DataRecord.Field2
ELSE
NULL
END AS response
FROM
ConfigurationTable AS config
LEFT OUTER JOIN
DataTable AS DataRecord
ON config.CustID = DataRecord.CustomerID
WHERE DataRecord.CustomerID = #CustID
ORDER BY
config.Ordinal
There are other ways to do this, in SSRS or in SQL, depends on more details of your requirements.