Tableau - Comparing one against an average of many on same worksheet - tableau-api

I'm looking to compare a single Fortune 500 company's revenues (selected by the end user from a list of all Fortune 500 companies) to an average revenue for all Fortune 500 companies over time. I would like the averages to show up as bars and the single company revenues to show as a line graph (both on the same chart).
I understand how to set two different chart types on the same view. What I don't understand is how to write the calculations and parameters to give the end user the functionality of choosing a single company and comparing it against all others.
Any suggestions on how to do this? Happy to clarify further if needed.
Thank you in advance!

I don't have Tableau right now to test, but I believe that kind of chart can be achieved using 2 measures.
Well, you need to create the measures then. The average of all is pretty straight forward, it's AVG(Revenue).
The single company revenue can be retrieved using parameters. Create a parameter like [Company chosen], and put the list of all Fortune 500 (you can load from field, which helps a lot).
Then create a calculated field [Company revenue]:
IF [Company] = [Company chosen]
THEN [Revenue]
END
And just use the sum or avg of this measure.
Put both the measures on the worksheet and set the right chart

I am using the superstore data that ships with Tableau.
You can create an LOD calculation to calculate the average:
SUM({FIXED [Order Date (Months)] : SUM([Sales])}) / SUM( {COUNTD([Sub-Category])})
This is calculating the total sales at each month and summing the sales and then dividing that by the number of points for each month (thereby giving you an average of sales per month).

FYI, I submitted this question to Tableau. They replied with a workbook using the Superstore data with the following instructions:
Add Year(Order Date) to the column.
Add Sales to the row.
Create a parameter called Select Country with the following settings:
Name: Select Country
Data Type: String
Allowable Values: List
Add from field: Country/Region
Select OK.
After creating the parameter, Right Click on the parameter in the data pane and select Show Parameter Control.
Create a calculated field Country Sale called with the following formula:
IF [Country / Region] = [Select Country] THEN [Sales] END
Add Country Sale to the Rows Shelf.
Go to Sum(Country Sale) tab on the Marks Pane and select Line from the drop down.
Right Click on the Country Sales axis and select Dual Axis.
Right Click on the Country Sales axis and select Synchronize Axis.

Related

Power Bi Clustered Column Chart to show % or row total

I am using Power Bi to produce several reports, one of it is the NPS score for support. However, I am coming across an issue with the clustered column chart. It is showing the value against the total number rather than for each row.
What I want to see if the following (within Excel),
The NPS score is shown as a percentage for each week.
e.g. Week 3 has the Promoter at 95.5% and Detractor at 4.5%
However, when using Power Bi, I am shown the following, which is a Percentage of the grand total, instead of each week.
Using a Matrix, I could see the following as total numbers.
I can copy this Matrix and show it as a Percentage of each Row, which is also correctly showing the results.
I have the dates already set up using a feeder table to allow me to get the week number etc from a date within the main raw data, so they sort in the correct order..
My Chart is using the following table entries
Cal Week and WeekNo are both from the feeder table (Fiscal)
Net Promoter and Count of Case Num are from the RawData table.
How can I get the chart to show the percentages per week instead of the total?
I am also planning to use slicers to filter down further, for example, Regions (which are in the RawData).
I believe I will need to add an extra column to the RawData, but no idea what to put in it and then how to use that in the chart, and still allow it to slice.
Any help would be greatly appreciated.
Thanks
DD

Tableau desktop average line granularity error

[14 day sales trend,split by student type][1]
I was trying to plot an average line for the sales over the past 14 days. I have used average line in analytics pane for the entire table. And I have made bar chart to stacked bar chart by splitting the sales on each day with old/new student types. The average line was at ~470 when I tried without adding student type to "color" in marks card. The average line moved to 235 when I have added student type to "color" however the tooltip is showing ~470. The granularity level tableau taking is the student type but I need it at the day level. What change should I make to bring back the average line to the correct value i.e., 470 showing the student type details too.?
Two points:
As you stated, you have configured the average line to be calculated across the whole table, which should result in the average line calculation ignoring any more granular levels of detail. Since your line is moving as you add more dimensions to the view, this behavior indicates that you may have configured your average line to display AVG(Sales) Average, instead of SUM(Sales) Average. Right-click the average line and choose Edit. Then, change the Value selectors to SUM(Sales) Average.
When you add an average line from the analytics pane, this metric does not automatically also get added to the tooltip. So, comparing the value of the average line to what you have in the tooltip is likely not a valid, "apples to apples" comparison. Check to see if you may have added AVG(Sales) somewhere else in the view in addition to adding the average line from the analytics pane.

How can I adjust the cross tab order using a formula in Crystal Reports

I am trying to organize my cross tab labels in a specified order. The table shows students that have left the school by grade level and year. Grade level is dependant on an if - then formula because the database does not have the grade that students left the school. The grade level is calculated by subtracting the withdrawal year from their grad year and then applying a text string based on the result.
When I try to adjust to a specific order there is no option to select the individual groupings as my formula is not available in the common tab. The labels in the column are accurate but just out of order.
Any help would be greatly appreciated. I am fairly new to Crystal reports. Perhaps I am not understanding how a cross tab works or perhaps there are problems with my formula.
current view of order
Cross tab expert view
Easiest solution is to change the formula that generates the labels so they sort alphabetically as you wish. You can pad the numbers with a zero so that '1' becomes '01' or prepend the text with a counter (01., 02., etc.).

Aggregating data from the US stock market in Tableau, using different time frames

I am a very basic user of tableau and I have not found an answer to my question.
I have a txt file that has historical daily data for 98% of all the stocks in the US, with their daily capitalization. Each stocks has its TICKER, Daily Market Value for every trading day of the year, and its SECTOR.
I did a simple time series that display SUM([Mktval]) (sum of all individual market values) across all stocks, on a daily daily, and where I can see that the total value as of 2016 is about 24 Trillion USD, as in the image below.
When I change the view column from DAY to YEAR, I don't see the right values, but something a lot larger. So I realized that I need to do SUM([Mktval])/252 to get the right value for a year (there are 252 trading days in a year).
If I change the view to MONTH, as in the chart below, the numbers are again wrong because 252 is not the right value to use in the division.
Is there any way that Tableau can adjust the values automatically to reflect the AVG MktVal across different time intervals?
Thanks
Replace SUM(Mktval) on the Rows shelf with the following calculated field
avg({ fixed day(Date1) : sum(Mktval) })
That solution is all in one step. It is perhaps a bit more clear to use 2 steps. First, create a calculated field called total_daily_market_value defined as
{ fixed day(Date1) : sum(Mktval) }
Then make sure that calculated field is a measure. It is an LOD calculation that you can think of as a separate table with one value for each day showing the total market value for that day.
Drag that measure to a shelf, and then change the aggregation function to AVG(), MEDIAN(), MIN(), MAX() or STDEV() as desired. Tableau will aggregate the total_daily_market_value using your chosen aggregation function for whatever values of Date1 are in your view.

Tableau Draw Financial Data Series

I am new to tableau. I am just trying the simplest task: I want to draw a stock price time trend. I have data and I have price. But no matter how I tried, tableau seems no option for this raw data drawing-- you have to select a measure, whether sum or average or count but no option for just raw data. Can someone tell me how to do this? Thx!
Sum should be fine and as you add dimensions the granularity will be determined. For example, Take one of your stocks and add the date to columns and the symbol to rows. Most likely you want to see daily close price so right click and change to exact date. At this point the sum shouldn't matter because you should only have one price for each day in your record. If you have hourly price data, I would suggest using close price or change the date to the hour level.
In the Analysis menu uncheck aggregate measures, then no aggregations are performed on the measures and you see all the values.