I have 2 tables:
Calendar table
Date
----
01/01/2022
02/01/2022
03/01/2022
.
.
.
Resource table
Resource Name
-------------
Resource A
Resource B
.
.
.
I want to combine both tables into one table with the following format:
Resource Name | Date
---------------------
Resource A | 01/01/2022
Resource A | 02/01/2022
Resource A | 03/01/2022
Resource A | .
Resource A | .
Resource A | .
Resource B | 01/01/2022
Resource B | 02/01/2022
Resource B | 03/01/2022
Resource B | .
Resource B | .
Resource B | .
.
.
.
How can this be done using either Power Query or DAX [PowerBi]?
In powerquery,add column, custom column
= NameOfOtherTableGoesHere
Then click the arrow atop the column and expand to rows
Related
I have multiple tables that have a UNIQUE key (ID) along with other attributes.
| TABLE 1 |
|-----|------------|--------------------|
|ID |NAME | DESCRIPTION |
|-----|------------|--------------------|
|01 | JOB01 |THIS IS A SAMPLE JOB|
|02 | JOB26 |ANOTHER SAMPLE JOB |
| TABLE 2 |
|-----|------------|------------------------|
|ID |NAME | DESCRIPTION |
|-----|------------|------------------------|
|43 | TRIG01 |THIS IS A SAMPLE TRIGGER|
|56 | TRIG26 |ANOTHER SAMPLE TRIGGER |
And I have a another table that has reviews. A review can be on a job, on a trigger, etc. on such other activities (activity tables). Any activity can have one or multiple reviews.
Here ID explains the relationship with other tables (table 1 and table 2).
Such as JOB01 has 2 reviews.
| TABLE 3 (REVIEW) |
|-----|------------|-------------------------------|
|ID |NAME | DESCRIPTION |
|-----|------------|-------------------------------|
|01 | REVIEW01 |THIS IS A SAMPLE REVIEW |
|01 | REVIEW02 |ANOTHER SAMPLE REVIEW ON JOB 01|
|02 | REVIEW89 |SAMPLE REVIEW ON JOB 02 |
|43 | REVIEW21 |ANOTHER SAMPLE REVIEW ON TRIG01|
|43 | REVIEW29 |ANOTHER SAMPLE REVIEW ON TRIG01|
Is it okay to create relationships like this in my data model for data analysis (I want to see the reviews related to my jobs, my trigers, etc.). Would it affect performance? (Considering approx. hundred thousand rows in each table)
Is it better to split table 3 up by the activity types no matter how many tables are formed?
Or do multiple 1:M relationships like this work fine.
I have table in RDS which consists two columns id and user activity at some time exactly values active/away.I get user activity every day so I need to add user activity column every day to that table.Any ideas how to do it?Now I have table with first two columns in RDS,but I am in stuck with how to add columns to that table
+-------------+------------+------------+
| id | 2020-08-13 | 2020-08-14 |
-----------------------------------------
| 12345 | active | away |
You could use an alter table ... add column, but this is not the right way to solve the problem.
In a relational database, you add additional rows for repeated data, not additional columns. So your table should look like this:
+-------------+-------------+------------+
| id | status_date | status |
------------------------------------------
| 12345 | 2020-08-13 | active |
| 12345 | 2020-08-14 | away |
Then you add a new row using an insert.
I have the following tables:
Table A:
___________________
| ID | NUMBER |
|__________|________|
| 10000378 | 1 |
| | |
Table B:
_________________________________________________
| ... | ID | Column 1 | Column 2 |
|____________|__________|____________|____________|
| ... | 10000378 | 7 | 2 |
| | | | |
Table A and Table B share the same ID value.
Not that it matters too much, the ID in Table A is it's key, and can be found in Table B.
Table A's NUMBER column tells me which Table B column to read.
For example:
IF
[Table A].[NUMBER] = 1
THEN
put the value of [Table B].[Column 1] into [Table B].[My Column]
... and so on
As a visual example (my desired result):
_______________________________________________________________
| ... | ID | Column 1 | Column 2 | My Column |
|____________|__________|____________|____________|_____________|
| ... | 10000378 | 7 | 2 | 7 |
| | | | | |
With My Column being the result I am after (which comes from Column 1 - as specified by Table A's NUMBER value for the ID of 10000378).
What I have tried so far
I have set up a 1-to-1 relationship between Table A and Table B (on the ID column`).
I then went into the Power Query Editor tried adding a Conditional Column:
But that doesn't allow me to reference Table A in any way.
So I decided to try the Append Queries as New option:
Selecting the Two tables radio button, setting Primary Table to Table B and Table to append to the primary table to Table B.
With the idea of creating the following structure from which I can get my desired result (but adding the NUMBER column, which I don't really want but can live with):
_____________________________________________________________________________
| ... | ID | Column 1 | Column 2 | NUMBER | My Column |
|____________|__________|____________|____________|_____________|_____________|
| ... | 10000378 | 7 | 2 | 1 | 7 |
| | | | | | |
Doing the append copied all of the contents of Table B and inserted the NUMBER column which is fine, but all the values in that NUMBER column are now null.
I don't understand why this is the case.
How can I achieve my desired result?
Appending queries is used when you have additional rows of data that you’d like to add to an existing query (i.e. union/union all in SQL). Joining tables in Power BI is called "merging":
You can find more details in Combine queries section of Tutorial: Shape and combine data in Power BI Desktop article.
Note that if you have a proper relationship defined between your tables in the model (also described in the article above).
To do this, first merge Table B with Table A and expand the columns you'd like to add to the table (Column 1 and Column 2).
Once you have that, then write your custom column, My Column:
if [NUMBER] = 1 then [Column 1]
else if [NUMBER] = 2 then [Column 2]
else <whatever you want to return if not 1 or 2>
I have one workflow which contain five sessions. I am looking for a query by using informatica repository tables/views which give me output like below. I am not able to get a query which give me desired result.
workflow-names session-names source-count target-count session-start time session-end time.
If you have access to Repository metadata tables, then you can use below query
Metadata Tables used in query:
OPB_SESS_TASK_LOG
OPB_TASK_INST_RUN
OPB_WFLOW_RUN
Here the Repository user is INFA_REP, and workflow name is wf_emp_load.
SELECT w.WORKFLOW_NAME,
t.INSTANCE_NAME,
s.SRC_SUCCESS_ROWS,
s.TARG_SUCCESS_ROWS,
t.START_TIME,
t.END_TIME
FROM INFA_REP.OPB_SESS_TASK_LOG s
INNER JOIN INFA_REP.OPB_TASK_INST_RUN t
ON s.INSTANCE_ID=t.INSTANCE_ID
AND s.WORKFLOW_RUN_ID=t.WORKFLOW_RUN_ID
INNER JOIN INFA_REP.OPB_WFLOW_RUN w
ON w.WORKFLOW_RUN_ID=t.WORKFLOW_RUN_ID
WHERE w.WORKFLOW_RUN_ID =
(SELECT MAX(WORKFLOW_RUN_ID)
FROM INFA_REP.OPB_WFLOW_RUN
WHERE WORKFLOW_NAME='wf_emp_load')
ORDER BY t.START_TIME
Output
+---------------+---------------+------------------+-------------------+--------------------+--------------------+
| WORKFLOW_NAME | INSTANCE_NAME | SRC_SUCCESS_ROWS | TARG_SUCCESS_ROWS | START_TIME | END_TIME |
+---------------+---------------+------------------+-------------------+--------------------+--------------------+
| wf_emp_load | s_emp_load | 14 | 14 | 10-JUN-18 18:31:24 | 10-JUN-18 18:31:26 |
| wf_emp_load | s_emp_revert | 14 | 14 | 10-JUN-18 18:31:27 | 10-JUN-18 18:31:28 |
+---------------+---------------+------------------+-------------------+--------------------+--------------------+
I am newbie in tableau. I have two data sources, an excel file and a connection database. I need to find a description ID in the excel file (table1), and paste it into the table database (table2).
Example:
The Excel file (table1):
+-------+---------------+----------------+
| Id | description1 | description2 |
+-------+---------------+----------------+
| 01:01 | soft | install soft |
| 12:04 | soft | uninstall soft |
+-------+---------------+----------------+
The connected database (table2):
+-------+---------+------+
| ID | group | name |
+-------+---------+------+
| 01:01 | IT | bob |
| 12:04 | Finance | joni |
+-------+---------+------+
This is what I want as output:
+-------+---------+------+--------------+----------------+
| ID | group | name | description1 | description2 |
+-------+---------+------+--------------+----------------+
| 01:01 | IT | bob | soft | install soft |
| 12:04 | Finance | joni | soft | uninstall soft |
+-------+---------+------+--------------+----------------+
How can I find this information using ID?
So to do this you should be able to connect both excel files to tableau. Therefore you will have two data sources. You then will form a relationship between the two sheets based on a common id, in this case it will be the field "ID". You can then drag in the pills you need to the shelf to form the table as above.
Connect both data excel data sources to workbook
Navigate to the sheet1 and you will see both data sources listed in the top left hand corner.
Select the first sheet and navigate to Data-> Edit Relationship(on the top menu bar)
Select the "custom" in the bullet menu
Select the add button, and in the pop window choose to link the data on ID to id
Select OK
Your data is now blended and you can drag in your fields from both data sources and get the results you listed.
Apologies for not sharing screen shots but I cant upload at the moment.
Here's a link on defining relationships.
http://onlinehelp.tableau.com/current/pro/online/en-us/help.htm#multipleconnections_relationships.html