Grant total of data using LOD in tableau - tableau-api

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)

Related

Tableau measure count items if between dates

What I am trying to achieve is to get a count of people employed in a particular period.
I have 3 variables:
Employee ID (integer)
Hire date (date)
Termination date (date or null)
Example
the formula I am looking for is something like
if termination_date is null
then
count employee_ID in
dates between Hire_date and max of either hire_date or termination_date
else
count employee ID in
dates between hire_date and termination_date
This aims to show the dynamic of staff level over the time.
I am new to Tableau, not sure how to even start with it. Any suggestions welcome.
This problem will be simpler if you reshape your data to have the following three columns
Employee ID
Date
Action. (where action takes on the values of ‘Hire’ or ‘Terminate’).
Each data row represents one change in status for an employees. If an employee had a termination date, they will have two records in this new format, otherwise just one record showing the hiring date.
You can reshape your data by hand, or leave the original and use Tableau Prep or the Tableau data source page to reshape using a self Union and a few simple calculated fields.
Define a calculated field called Staffing_Change as
if Action=‘Hire’ then 1 else -1 end
Now you can plot the change in staff level over time by putting exact date on columns and sum(Staffing_Change) on Rows. You can use a quick Table calc, Running Sum, to see the net staffing level. For line mark types, I’d use a step style by pressing on the path button on the Marks card. Otherwise, the chart can give the impression of fractional number of employees.

Crystal Reports Sum per date from 2 different reports

I have spent several hours trying to google my issue with no luck. I was wondering if anyone here would know how to do this.
I have 2 separate unrelated tables:
The first table has bank deposits(all deposits for a specific day) with the amounts example:
1/4/16 $10
1/4/16 $20
1/5/16 $15
1/5/16 $25
The second table has transactions from my billing software example:
1/4/16 $5
1/4/16 $12
1/4/16 $17
1/5/16 $22
1/5/16 $2
1/5/16 $4
I need to create a report, so that I can pull the sum for each day-
1/4/16 - first table sum: $30 - second table sum: $34
1/5/16 - first table sum: $40 - second table sum: $28
Is this possible? If so, how can I do this. I can get the sums for each table separately by using a group on the specific date field but I can not figure out how to do them both at the same time.
I you don't want to do much on database then create two sub-reports
Group data on date for both reports(Suppress details and header if you don't need them).
In both report Place Group name then First/Second table sum then Grand total Summary for your amount field.
Place both reports in front of each other and align them base line.
This will hopefully work for you if min date in both tables is same.
If min date is different then you can create a view or stored procedure to join data and just group it on date.
You can link both the tables using joins on date column and just group by date and take summary in group footer
Edit.......
I assume your last record will be duplicated so use running total.
Create a new running total
First select the field to summarize.
Second evaluate select radio button on every record
Third reset...select on change of your calculated field.
Suppose if you are summarizing amount field then
Filed to summarize: select amount
Evaluate: select for every record
Reset: on change of field amount

How do I add multiple subtotals in tableau?

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.

MDX Calculated Measure for Customer and Route by Day

I'm working with a cube that needs a new calculated measure and I'm having a difficult time getting the MDX right.
The scenario that I'm looking to measure is a count of days where for a given Customer (by Customer Name) and Delivery Route (also on the Customer Dimension) the total sales amount is greater than 0.
The date hierarchy is fairly straightforward.
Date > Year > Month > Day
In the customer dimension, we are not going to be using a hierarchy.
customer name
delivery route
On the measures, we only really care about total sales
total sales
So, I've tried a little bit of everything, but I'm not sure I'm approaching the problem in the right way and that could be that I'm less familiar with MDX.
Here's a sample of data and what my end goal would be.
What I've tried to get there has been the following (however, nothing has provided what I need).
WITH MEMBER [Measures].[count deliveries]
AS
COUNT(FILTER(DESCENDANTS([Date].[Calendar].[Year].&[2013],2), [Measures].[total sales] > 0) )
SELECT NON EMPTY {[Measures].[total sales]
, [Measures].[count deliveries]} ON 0
, NON EMPTY ([Customer].[Customer Name]
, {DESCENDANTS([Date].[Calendar].&[2013],2)}) ON 1
FROM [Sales]
THE END GOAL
I would like to have this added as a calculated member to the cube and not just in query format. Any help would be appreciated!

How can I report a percentage of the total count in the detail of a crystal report?

I'm trying to get the total count of employee ids so that I can use it as the basis for a percentage in my report. I'd like my report to look like this:
Types With Email
Customer 20% 15%
Vendor 40% 80%
Employees 40% 75%
Total People: 100
In my view I have the employee id, type and email address. I can get the count and the first percentage (percentage of customers, vendors and employees). What I'm have trouble with is the percentage of customers or vendors with email address. I've tried using formula fields and summaries, but haven't gotten too far with them. Can anyone point me in a direction?
Create a formula to calculate email-address presence:
//{#has_email}
If Isnull({employee.email}) Then
0
Else
1
It doesn't need to be added to the canvas.
Create a formula to calculate the % total:
//{#email %}
// summarize number of email address for a given type
Local Numbervar Total := Sum({#has_email}, {employee.type});
If Total <> 0 Then
Total / Count({employee.id}, {employee.type}) * 100
Add to group header or footer and format with %.