VLOOKUP function in Tableau - vlookup

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

Related

How to toggle between two maps in a same map

I have a table of clients that specifies their state and their city.
like this:
_________________________
| client | state | city |
| 1 | texas |dallas|
| 2 | texas |austin|
| ... | ... | ... |
|________|_______|______|
I want to have a map in which i can choose to show the states in which i have clients and then have the option to toggle to another mode that shows the cities i have clients in.
Is there a way to do this in power bi?

Single Filter for PowerBI

I have 2 tables in powerbi, one contains all transactions to and from people (each client identified with an id, where "I" can be either the receiver or sender of $) and the other is the detail for each client.
Table 1 would look something like
| $ | sender id | receiver id |
|---|-----------| ------------|
| 10| 1 | 2 |
| 15| 1 | 3 |
| 20| 1 | 2 |
| 15| 3 | 1 |
| 10| 3 | 1 |
| 25| 2 | 1 |
| 10| 1 | 2 |
The second table contains sender id and name:
| id | name |
|----|-------|
| 1 | "me" |
| 2 | John |
| 3 | Susan |
The expected result is something like (not necesarily in a table, just to show)
| $ sent | $ received | Balance|
|--------|------------|--------|
| 55 | 45 | +10 |
And in a filter have "John" and "Susan" so when i Select one of them i could see $ sent, $received and balance for each of them.
The problem of course is that i end up with one active and one inactive relationship so if i apply such a filter i end up with 0 in sender/receiver and the whole value in the other (depending which is made active and inactive) and if i make another table that's "id sender"+"name sender" then i cant filter all at once.
Is it possible to do this?
I hope this is kinda understandable
You will need to add 2 columns to your user table
received = CALCULATE(SUM(T1[$]), Filter(T1, UserTable[id] = T1[reveicer id]))
The same you can do for send. Now in your visual, use the new columns.
Enjoy!
after going around a bit I found a way to solve this, probably not the most orthodox way to do it, but it works.
What I did is to add 2 columns to my sales table, one was labeled "movement" and in sql it is just a 'case' where when the receiver is 'me' its "Charged" and when the receiver is 'not-me' its "Payment", then i added a column with a case so it would always bring me the 'not-me' id, and i used that for may relationship with my users table.
Then I just added filters in my cards making one a "Payment" card and the other a "Charged" card.
This is all following the previous example, it was actually just a bit more tricky as I could actually have a payment from me to myself, but thats just another "case" for when it was 'me-me'
Hope this is understandable, english is not my first language and the information i actually used is partially confidential so i had to make the above example.
thanks all and have a nice day.

Add column to existing table in rds

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.

query to give workflow statistics like source count,target count,start time and end time of each sessions

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 |
+---------------+---------------+------------------+-------------------+--------------------+--------------------+

How to get a list of hosts connected to a mysql server

I am trying to get a list of hosts connected to a mysql server. How can i get this?
What should i do after connecting to the mysql server.
Code snippets will really help.
Also whats the best api to use to connect to mysql using c++?
One way you could do it is to execute the query show processlist, which will give you a table with Id, User, Host, db, Command, Time, State and Info columns. Remember that your show processlist query will be part of the output.
You can try this query: select distinct host from information_schema.processlist;
For example, there are multiple connections from 10.9.0.10 and one local connection.
mysql> select distinct host from information_schema.processlist;
+-----------------+
| host |
+-----------------+
| 10.9.0.10:63668 |
| 10.9.0.10:63670 |
| 10.9.0.10:63664 |
| 10.9.0.10:63663 |
| 10.9.0.10:63666 |
| 10.9.0.10:63672 |
| 10.9.0.10:63665 |
| 10.9.0.10:63671 |
| 10.9.0.10:63669 |
| 10.9.0.10:63667 |
| localhost |
| |
+-----------------+
12 rows in set (0,00 sec)
If you want only hosts (not different connections), you can try something like this: select distinct substring_index(host,':',1) from information_schema.processlist;
Example:
mysql> select distinct substring_index(host,':',1) from information_schema.processlist;
+-----------------------------+
| substring_index(host,':',1) |
+-----------------------------+
| 10.9.0.10 |
| localhost |
| |
+-----------------------------+
3 rows in set (0,00 sec)
You can see, that MySQL shows me one empty row, it is normal (i have a deamon process):
mysql> select distinct substring_index(host,':',1),`command` from information_schema.processlist;
+-----------------------------+---------+
| substring_index(host,':',1) | command |
+-----------------------------+---------+
| 10.9.0.10 | Sleep |
| localhost | Query |
| | Daemon |
+-----------------------------+---------+
You can remove it with where `command`!="Daemon" or where `host`!=''
And here is good link with query which also count connections from host and show which users are connected: http://blog.shlomoid.com/2011/08/how-to-easily-see-whos-connected-to.html