How do I add multiple subtotals in tableau? - tableau-api

My report has the following structure
ID , Currency, Subdepartment, Unit , Revenue, Salary
I wanted to print the subtotals of Revenue and Salary for the following combinations
(ID, Currency, Subdepartment)
(ID, Currency, )
The row has discrete dimensions hence the default grandtotal/subtotal option is not working .
is thr an alternate to calculate the subtotals and display beneath each grouping.?

If you're hoping to see this in a single worksheet, it sounds like a job for LOD (level-of-detail) functions. I'm not sure how you want to visualize it, but here's how you could simply make a table.
Create some calculated fields:
Revenue Total (ID, Currency)
{ FIXED [Id], [Currency] : SUM([Revenue]) }
Salary Total (ID, Currency)
{ FIXED [Id], [Currency] : SUM([Salary]) }
We can then create a table (for example) with the subtotals and totals by placing the following pills in the Rows shelf, in this order:
[ID]
[Currency]
SUM([Revenue Total (ID, Currency)]) (Make it discrete)
SUM([Salary Total (ID, Currency)]) (Make it discrete)
[Subdepartment]
SUM([Revenue]) (Make it discrete)
SUM([Salary]) (Make it discrete)
The resulting table will look something like this:
ID Currency Total Revenue Total Salary Subdepartment Revenue Salary
----------------------------------------------------------------------------------
A Dollars $200 $100 R $140 $30
S $60 $70
Manat ₼4000 ₼8000 R ₼1000 ₼7000
S ₼3000 ₼1000
Yen ¥500 ¥1000 R ¥100 ¥300
S ¥200 ¥500
T ¥200 ¥200
B Dollars $300 $700 R $200 $600
S $100 $100
Manat ₼7000 ₼3000 R ₼2000 ₼1000
S ₼3000 ₼1000
T ₼2000 ₼1000
Yen ¥900 ¥400 R ¥150 ¥100
S ¥250 ¥100
T ¥300 ¥200
All that said, FirebladeDan makes a great point in the comments of your question. Tableau is NOT Excel – it's a visualization tool, and a smokin' one at that. If you want to show aggregations of measures at different levels of detail, your best option (both in terms of what Tableau can easily do and the clearest way to visualize it) is usually going to be to create a dashboard with multiple worksheets at different levels of detail and to take advantage of filter actions and other controls to see how it all relates.

Related

Grant total of data using LOD in tableau

I am new to tableau & having data in the form of the below input dataset.
COMPANY Id,Name,Month,Salary
1,SAM,AUG,10000
1,JOHN,JUL,20000
1,JACK,AUG,30000
2,TOM,AUG,20000
I need output in the below form
COMPANY ID, MONTH, MONTHLY SALARY, TOTAL SALARY,PERCENTAGE
1, AUG,40000,60000,66%
1, JUL,20000,60000,33%
I am able to calculate the Monthly salary & Percentage. But I am not able to find the grant total of salary. It is giving Monthly salary only there as well. I used below formula in calculated field but it doesn't work. Can you please help me
SUM(IF [COMPANY_ID] = '1' THEN SALARY ELSE 0 END)

Grouping customers as "others" if sum of sales is below a value

I want to build a logic in tableau for grouping customers. Basically I want to see a bar graph comparison of customers sales with below logic:
Customers whose respective sum of sales is less than 100,000 are grouped as "Others" and shown as one bar
Customers whose respective sum of sales is more than 100,000 are shown as individual bars
Please let me know if there is a solution already discussed for this query or for any further details needed to support my question, thanks
if {fixed [Customer Name] : sum([Sales])} > 100000 then
[Customer Name]
else
"Other"
end

Count records as proportion of total in Tableau

I have data with sales, details including gender, location, date, etc. There's one row for each sale, so the total number of sales is a count of the rows.
customerid sale_date regionid studentid sex
18761372 01/09/2016 AFB07458 C2F815C6 1
18761372 01/09/2016 AFB07459 206AA234 0
07189635 01/09/2016 AFB07460 F218C8F1 1
07189635 01/09/2016 AFB07461 F021CD27 0
07189635 01/09/2016 AFB07462 E6145555 1
I'm trying to produce a line graph that shows number of sales by month, split by male and female. However male sales are ~5million for the year, and female are ~13 million. So it's hard to compare whether there's any difference in how the sales vary by month (i.e. whether males are proportionately more likely to buy in september).
I manage to get this to work by creating the following calculated field:
If [sex] = 0
THEN 1/5000000
ELSE 1/13000000
END
This does what I need, but it's not a great solution as it involves me manually checking what each total is and writing it down (admittedly not much of an issue with sex, but if I'm doing it on something with multiple fields then it would become very time consuming.
Is there a way of doing this more elegantly? I tried to use sums and case statements in there but I got "cannot mix aggregate and non-aggregate arguments".
I would approach this with a calculated field that shows a percent of total, by month.
Right click on your pill, select 'Quick Table Calculation' and choose 'Percent of Total'.
That way, instead of looking at a count of orders where one group always appears greater, you are looking at their share which will be more uniform.
Maybe I'm understanding this wrong but it seems fairly straight forward. Using the sample data provided I just:
Add the date field pill "sale date" to the column shelf(set it to pull back the month)
Drag the "number of records" to the rows shelf(automatically sum the results)
In the "Show Me" section in the top right select line chart.
Drag the sex pill onto the color card, this will break the line into to two, one for male the other for female(you may have to convert the sex pill to a dimension, to do this right click the pill and select "convert to dimension")
Let me know if this solves it for you?

Summing by Department with conditional sum

My income statement requires a column for each department in our business. Each of my six departments have their own Sales, Cost of Sales, Gross Profit, Overhead, and Net Income.
The view from the database contains columns for GL Number, Department Number, and Amount for every transaction. I can tell if its Sales, Cost of Sales, etc from the identifying GL Number. I am able to get all of the pertinent information from one view, however I don't know how to arrange it on the report.
I created an initial version in Excel using the Sumifs function. How can I get the same arrangement of data in Crystal Reports?
Running Totals can be configured to only count records that meet given criteria. When creating the RT, select "sum" as the type of summary and "Use a Formula". In the "x-2" screen, write logic to filter out anything that doesn't meet the criteria you want.
Simple way would be group by report by GLNumber and place all fields that required sum in details and insert summary in group footer.

Crystal Reports: Converting Selected Row Data to Column Data

Is it possible to transpose data for a select column in Crystal? Here is my issue... I am using ttx file to get data fields for the Crystal Report...
I want only the tax_type and the tax_rate and tax amount to show up in the same row as the product sold. The tax_rate is stored in a separate table that needs to be pulled in as a column as well. I need to group and sum on product, buy, sell, tax_type, and then net the whole amount to come up with net total which I kinda know how... but I am stuck at transposing a row. Basically I only want to show row as column where tax type, amount, and rate matches transaction number and YN_tax == 1. The tax rate is stored in a totally separate table... Mind you that tax will not be applicable to each transaction... Here are the table Details
Details Table
Transaction Sales_Date buy_sell Product location ProductType price amount YN_tax tax_type
123456 11/9/2014 Sell DEF Brazil trinkets 5 703.08
123457 11/9/2014 Sell ABC Canada widget 10 213.5
123458 11/9/2014 Buy DEF Brazil trinkets 2 630
123459 11/9/2014 Buy DEF Brazil trinkets 3 34.41
123457 11/9/2014 Sell ABC Canada SalesTax 3 688.2 1 SalesTax
123458 11/9/2014 Buy DEF Brazil FederalTax 2 132 1 FedTax
Tax Rates Table
title rate
SalesTax 8.25
FedTax 9.75
You can do it follow below process.
Before proceeding link the table so that you get title and rate.
Create a formula for every column as you want in the report and write formula as below.
if YN_tax =1
then tax_type
Above formula is for column tax_type in the similar way create individual formulas for all columns.