Tableau---Getting count from 2 different data sources and combining into one total - count

I am a tableau newbie and am trying to see if this is possible or not. I have 2 separate data sources where the same employees are listed, one is for closed cases and the other is for open cases. These data sources have some of the same columns, but for the most part they are different.
Is it possible to aggregate the case count for each employee on the closed and open data sources into a single column? For instance, if an employee has 50 closed cases and 23 open cases, I want it to show 73 for them.
I attempted to play around with the joins/unions but these didn't work properly and duplicated the data most times.

I think this is a great chance to leverage blends.
I have created a workbook with the Sample Superstore Excel dataset. This dataset has three sheets. I'll use the Orders and Returns sheets to demonstrate how we can calculate the net orders using blends.
The dataset I'm using can be found here.
Start by connecting to both the Orders and Returns separately. Once done with this step you should see the two data sources at the top of your data pane.
In this example, I'll calculate the Net Returns by Category. In your case, you're after the Total Cases by Employee, so just imagine Employee in place of Category.
Next, drag Category from the Orders data source onto the view, then select the Orders data source and click the chain icon to blend on Order ID.
You will need a common column between the two tables in order to blend.
Once blended I'll go back to the primary data source (indicated by the blue check mark) and create the Net Orders calculation.
This calculation uses the dot notation - similar to what you might see in SQL - to reference our other table.
To double check that our calculation is working properly, we can drag the components of this calculation onto the view and do the math.
Of course, once you are satisfied you can remove all but your blended calculation.

Blending isn't ideal in most cases but you could try it. Bring in each data source separately and "join" them within your workbook pane on Employee or hopefully an Employee_id. Click the little chain once you have them both loaded and you are on a worksheet tab. Then you could sum the counts by employee. Blending sometimes presents some issues with calculated fields across the two data sources but this is what I would try first.

Related

A way to search multiple lists and return a query for which list it belongs to

I have a csv file with multiple lists. See picture. What I want to do is query every single value so it tells me which list that the value is found in.
Eg I query number 898774 and it tells me 898774 - prim6 in set 1, set 2 and set 4.
I did find a quick work around by making one big list in excel, removing dupes and then manually searching all for each number. Doable for a small amount but not that good for '000s of sets.
I created a vector for each column and started a search with which(sapply) but then remembered I needed the names. Just a little bit out of my knowledge.

Powerbi equivalent to SQL having function

Im a trainee working with databases.
Im working on PowerBI report based on SQL query where all of the needed joins are included for my data to be obtained. So Im working within one dataset.
I have made a table where I can show number of transaction(like invoice number) and name of person that made that transaction. My problem lies in creating a measure that will influence that table. It should work like a having clausule from SQL (well at least my boss said that).
I would like for this measure to force this table to show only data for people that have made more than 2 transactions (they have more than 2 invoice numbers [so there are more than two rows for this person]) .
I tried to do it by writing a measure like that:
Measure = COUNTAX(
Query1;counta([Salesman])>2)
Or like that:
Measure 2 =
FILTER( Query1; counta(Query1[Salesman])>2 )
But i only got a bar graph that is showing me how many transactions were made by each person. When Im adding this measure to this table i see that for each row i got value 1.
Im new to the PowerBi and DAX so it's quite a big hurdle for me. Can someone share his/hers knowledge to help solve this problem? I would be much obliged.
I found a solution for my problem.
I created a second query that counted transactions for each person with their names. I created relationship between my two queries. Next I added counting attribute to my table with data from query one and I used filter on my counting attribute. After that this attribute can be just hidden and It works perfectly.
On top of that I created a measure and made a chart using this measure. It looks nice and clear.
The measure looks like that:
Measure =
COUNTAX(
Query1;counta([Salesman])
)
I filtered this measure too to get wanted result.

(Abandoned) Sort 2 models based on 1 column in Qt

I've 2 QStandardItemModel where the first model holds data and the second one holds a summary of that data (earnings per day on 1st model and earnings per week on the 2nd. Each row is a productive unit and each column is a day/week).
Both models appear on separated QTableView and I'd like to be able to sort one model and affect the other, so the data of both models would always correspond to the same productive unit.
I want the user to be able to see daily data (and scroll through it) while seeing the weekly data at the same time, which is why I don't make a single model.
Currently, I'm using a QSortFilterProxyModel to handle the sorting, but that doesn't sort both models at the same time.
How can I sort them at the same time?
I found no solution for this problem. Instead I sorted it by choosing a less-than-ideal single QTableView. I'm thinking of allowing the user to set a max of summary columns to avoid them from overflowing the table (I haven't gotten to that yet).
Anyways, I just wanted to say that I consider this question abandoned

Cognos Report - same query multiple times with different parameters to multiple tabs of 1 XLS

I need to produce a Cognos Report that produces 12 tabs. Each tab contains the same sort of report simply run for a different parameter value, for example, the month of the current year. I would like to reuse the SQL and define it only once and have this SQL accept a parameter.
I'm very new to Cognos 10 Report Studio. Can I use the Event Manager to execute a single report once with 13 parameters but yet combine the results in a sdingle XLS with 12 tabs?
I know I can split the results of a single query across multuiple XLS tabs, but i need to run the same query multiple times with different parameters...
I've only seen a 5 min demo of Event Mgt, not sure if that's even the place. Any direction to a newbie would be appreciated.
Depends on how "different" the parameters are.
If you want to split the values of one data item across separate tabs, such as a tab for each month of the year, use Page Sets. Write one query, create one list/report object. Then Section the list and tie to the Page Set construct in the Page tab. Example
A report created in Report Studio with different Pages will also export to different Excel tabs. If you have to split on a combination of 2+ data items with different values, you'll have to use different pages and queries. You can't re-use one query and plug in different values for each page. So, copy the primary query object and re-write to use parameter(s) unique to each page. Your prompt page may get a little large, but this is the standard method to create a "book" of reports.
Event Manager is for triggering report execution based off changing data. The classic example is to send a "Thank You" note to a salesman when he logs a sale of $1m or more in the database.

Array calculation in Tableau, maxif routine

I'm fairly new to Tableau, and I'm struggling in building some routines that could be easily implemented in Excel (though it would take forever for big sets of data).
So here is the deal, consider a dataset with the following fields:
int [id_order] -> id of the sales order (deepest level, there are only unique entries of id_order)
int [id_client] -> as I want to know who bought it
date [purchase_date] -> when the customer bought the product
What I want to know is, for each order, when was the last time (if ever) the client has bought something. In order words, what is the highest purchase_date for that user that is smaller than current purchase_date.
In excel, approach is simple (but again, not efficient)
{=max(if(id_client=B1,if(purchase_order
Is there a way to do this kind of calculation in Tableau?
You can do this in Tableau using table calculations. They take a little time to understand how to use well, but are very powerful and flexible. I posted a sample Tableau workbook for a similar question in an answer for SO question Find first time a condition is met
Your situation is similar, but with the extra complication that you want to repeat the analysis for each client id, so you might want to try a recursive approach using the Previous_Value() function instead of the approach used in that example - though I'm not certain that previous_value() will fit your situation.
Still, it might be helpful to download the example workbook I mentioned to get an idea how table calculations can address similar problems.
Just to register the solution, in case someone has the same doubt.
So, basically the solution I found use table calculation, which is not calculated until it's called on a sheet (and is only calculated on the context of the sheet). That's a little bit limiting, so what I do is create a sheet with all the fields I need (+ what is necessary for the table calculation) then export the data (to mdb) and connect to this new file.
So, for my example, the right table calculation is (let's name it last_order_date):
LOOKUP(MAX([purchase_date]),-1)
Explanations. The MAX() is necessary because Lookup (and all table calculations) does not work with data directly, only with aggregations. You can use sum, avg, max, attr, whatever suits you. As in my case there will be only 1 correspondence, any function will do just fine and return the same value.
The -1 indicates that I'm looking for the element immediately before the current entry (of the table, as you define it). If it were FIRST(), it would go for the first entry of the table, and LAST() would go for the last.
Now, I have to put it on a sheet. So I'll bring the fields id_client, id_order, purchase_date and last_order_date.
Then I have to define the parameters of my table calculation last_order_date (Edit Table Calculation). I'll go to Compute using and choose advanced. Now I'll do Partitioning: id_client, and addressing all the rest. What will that do? This mean Tableau will create temporary tables for each id_client, and table calculations will use those tables as parameter.
Additionally, I will Sort by field purchase_date, Max (again the aggregation issue) and ascending, to guarantee my entries are in chronological order.
Now, what will it do? For each entry it will access the table of the id_client, and check what was the purchase_date that is immediately before the current entry (that is being assessed), exactly what I need.
To avoid spending Tableau processing in Visualization, I often put all the fields in details (and leave nothing on screen), use Bar chart (it's good because it allows me to see the data). Then I export it to mdb, then connect to it again. Unfortunately Tableau doesn't directly export to tde.

Resources