Link dimension from one datasource to Measure in another in tableau - tableau-api

I'm new to Tableau and I'm trying to make measures from one data set dependent on a Dimension in another.
So I'm trying to link Expenditures of 2000,2012 and 2013 of one data source with year dimension which has only three values (2000,2012 and 2013) in another data source
Basically at the end I just need one Average Expenditure with its value for the corresponding years.

To link the two data sources by year, you will have to picot the table to bring it from a wide format (having each year in a separate column) to a long format (having each year in a separate row).
In Tableau go to the Data Source tab and select the three Expenditure columns, then right click on the header and choose "Pivot data".
That should bring your data in the correct format:
CountryA 2000 XXX
CountryA 2012 YYY
CountryA 2013 ZZZ
CountryB 2000 AAA
...
You might want to rename your columns to [Year] and [Expenditure] for example and you will have to create a calculated field with Right([Year], 4) to get only the year out of your former field name.
Now you can click on "Data" in the menu on the top and select "Edit Relationship", there you can choose the field with the year in one data source and the newly created calculated field in the other data source.

Related

Quarter calculation showing multiple month

I have four crosstabs, the first three are the 1st, 2nd & 3rd months that make up a Quarter. The fourth crosstab reflects the total of that Quarter all together. I have the ‘Month’ Dimension filtering on QUARTER(month) for the fourth crosstab.
What I would like is to have a calculated field or parameter that controls the months displayed in the first three tables dependent on what Quarter is selected.
For instance, Q1 2018 for crosstab #4 and the first three crosstabs show Jan-18, Feb-8 & Mar-18. Or when the Q3 2017 is selected then Jul-17, Aug-17 & Sept-17 is shown.
Apply the QUARTER(Month) filter from the sheet to the individual month sheets as well. This will filter all sheets to the chosen quarter.
Create calculated fields to filter the individual month sheets to single months.
a. Create a new calculated field. Name the field "!Month 1 Filter", insert the following expression, and click Ok.
DATEDIFF('month',DATETRUNC('quarter',[Month]),DATETRUNC('month',[Month]))=0
b. Create a new calculated field. Name the field "!Month 2 Filter", insert the following expression, and click Ok.
DATEDIFF('month',DATETRUNC('quarter',[Month]),DATETRUNC('month',[Month]))=1
c. Create a new calculated field. Name the field "!Month 3 Filter", insert the following expression, and click Ok.
DATEDIFF('month',DATETRUNC('quarter',[Month]),DATETRUNC('month',[Month]))=2
Filter each month sheet with its respective filter.

Tableau Running Sum doesn't calculate for all months

My data looks like this:
Month Profit($)
June 2018 100
In my Tableau Grid, I have setup a Running Sum table calculation (RUNNING_SUM(SUM([Profit]))) to project the cumulative profit until Dec 2018.
It doesn't work if the above is the only row in the underlying data! (I want the 100 to carry over to all the future months until Dec).
But it does work, if there is are rows until Dec 2018 in the underlying data.
(I don't want to add any kind of dummy rows in my underlying data because this is a very simplified scenario and my actual scenario is way too complex to add dummy rows.)
For this we doesn't have the direct solution.
for a workaround I have created an excel sheet having the details of all the Months in a Year and connected it with the current data set as a Full Outer join.
It will give you the date field in the Dimension pane of Tableau, use that in the columns Pane and Click on Show Missing Values.
You will get the desired results.

How do I filter a view based on criteria from a secondary blended data source?

Upfront:
Tableau 2018.1.1
1st (Primary Datasource) is a data source published to Tableau Server
2nd (Secondary Datasource) is a data source published to Tableau Server
1st is blended with 2nd based on a date field. There is a many to one relationship.
1st has multiple rows per date.
2nd has only one row per date.
2nd has a field called 'category' that is blended. There is only one category per date. Every category will have multiple dates associated with it.
The hard part, AKA why I'm here:
For the most recent date that's less than today... (which will be
the same in 1st and 2nd dataset)
I want the category of that one date
I want to filter the data for all dates that have that same category
What I've accomplished:
I can do part 1, but I can't get part 2 to work to even start on part 3.

Tableau - Similar function to SQL Group by

I have recently started using Tableau but am still very new to it. I don't know enough of the Tableau vocabulary to be able to find this answer through brute force googling. Hopefully some one here can help point me in a good direction.
I have a simple table of data, containing the columns and types: Date (Date), ID (Numerical), and Status (Text)
I want to be able to generate a report that has: Date, and Percent of the IDs on that date where the Status is "Complete."
In SQL I could do this by running a query along the lines of:
select date, (count(status like "Complete")/count(status)*100) from table
group by date;
Where can I look for this in Tableau? I tried creating a new Calculated measure in the sheet I am working on, but I couldn't find any built in functions that would add this ability. Thanks for any assistance.
So this should be pretty easy. In your tableau screen(when in a sheet) on the left you will see a column which is broken into two. On the top are the "Dimensions"(these are the things you will organise your data on, usually strings or dates) and on the bottom are the "Measures"(these are integers).
So under dimensions you should see "Date" and "Status". In the Dimensions you should see "Number of Records" and "ID"(this is your variable, you can convert it to a dimension by right clicking and selecting that option).
So what you need to do:
You just want status = complete, so drag your "Status" field into the Filter box(just to the right of the dimension column). You will get a pop up of the different types, select "Complete".
This has filtered your data source for only complete rows.
Drag you "Date" field to the "Rows" shelf, on the top of the screen. This will default to the Year of the date.
It will automatically go to a bar chart, change it to a table by selecting "Show Me" on the top right and select the table icon.
Double click on your "Number of Records" measure. This will add it to your sheet. This will now be auto summed per year.
To convert it to % of, right click on the measure in the Marks window(it should look like a green box "SUM(Number ....)"). Right click and select the option "quick table calculation", here select "Percentage of Total".
You will now have the % total per year for all records where status is equal to correct.
(Optional) - To adjust the date dimension, right click on the "Date" Pill(its up the top in the rows shelf). Hear you can see different options for quarter, month, day. You can change it to any of these or a custom data format.

Tableau -- find total sales of the month

I have date-wise data of a month in Tableau and I want to know total sales of the month. Can anyone show how to do it?
Here is the snapshot of the issue:
First of all, I would advise you to go to the "Data Source" Panel on the bottom left and change the data type of the dimension "Date" to date instead of string. If this is not possible, please speak with your datasource admin. It might be a problem, that the dates are in different formats (like "1.07.06" and "1.11.2016").
After that you can simply choose the discrete MONTH(Date) dimension by rightklicking (blue pills). If you display data ranging over different years it is advised to keep the "YEAR(Date)" blue pill.
In the sample data it looks like this:
Steps to get total sales month wise
Drag your date into column shelf and change by Right click on date and change into month.
Drag sales into row shelf and Right click on measure and go into sum.so you will get total sales per month.