I am using Tableau 8.2,I want to show calculations for current as well as previous year,how to apply this dynamically? it is getting possible if the year is written manually but it will be only temporary solution, how to do that dynamically?
i.e on applying filter Year=2013 then sales and orders value of current-1 year should be displayed
I have sales and orders On the Columns.
A quick solution to this would be to create a new calculated field for previous year sales by using the Lookup function.
For example:
LOOKUP(SUM([SALES]),-1)
You can simply introduce two calculated fields which will give you the current and previous year. These can be used on the rows and columns shelves or any where else depending on whether your aiming for chart, text table or any other viz.
Calculated field 1 = Current Filter
if datediff('year',[Date],TODAY() )=0 then 1
ELSE 0
END
Calculated field 2 = Previous Filter
if datediff('year',[Date],TODAY() )=1 then 1
ELSE 0
END
The formulas above can be used if the required measure is just a count otherwise you could replace: then 1 with then [Amount] or whatever measure this applies to.
Create a parameter and use IF Year = 'Parameter Value'THEN Sales ELSE 0 END
or use LOD to know the Max Year if you want it to be more dynamic: IF Year = {FIXED: MAX([Year])} THEN Sales ELSE 0 END
Related
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.
I want to find the number of customers per subscription plan at the end of the acquisition month.
As you can see in the workbook, customers can change their subscription plan on any date, but I only want to find the subscription plan at the end of the acquisition month.
I created a field, called EOM Acquisition, but need to find the desired output below for any given month of acquisition. (in sample dataset only October).
How can I do that? Thanks in advance!
Please proceed like this. Create a new calculated field say calculation1 as follows-
IF [Date] = [EOM Acquisition] then [Subscription Plan] END
drag this field instead of subs plan in view and filter out null values, you'll get what you want
Another way add a calc field as follows
IF [Date] = [EOM Acquisition] then 1 ELSE 0 END
And thereafter add sum on this field as measure alongwith EOM and subscription fields.
I have a data in database which gives me 8 rows based on date range out of which 5 are HCT, is there any formula in crystal report where I can get that count of those 'Abbr' ?
I am comparing HCT text from Dynamic report selection, I need to know can we create a variable which gives us count of 'Abbr'.
like for
HCT should return 5
US should return 2
RN should return 1 value.
UPDATE 1:
Here is what I am trying to do. I have secondary selection criteria as Dynamic report along with date range.
in the above example I have selected only "HCT", now even though sql data is returning 8 rows (HCT,US,RN) I need only the HCT count i.e. 5.
If I select "HCT" and "US" in the secondary criteria then I should get count of both HCT and US i.e. 5 + 2 = 7.
if I am not selecting anything then it should return 0, so irrespective of the data from DB, the value should be summed based on selection of my criteria.
am I clear enough?
Use Running Totals.
Specifically, make a Distinct Count running total for each Date Range code. You can set a formula in the Running Total Wizard to only evaluate records where, for example, {DateRange} = "HCT"
I found the solution for my question, I am just putting it here so that someone may help for the above mentioned formula.
This is what I did
Created a Formula(not running totals) by name SumOfSkills
if({Command.GlobalSkillAbbr} in {?GlobalSkill}) then 1 else 0
here Command.GlobalSkillAbbr is my "HCT" and '{?GlobalSkill} will contain all Global skills.
and used another formuala to sum it up.
Sum(SumOfSkills)
which gives me desired output.
I have a report with the following structure:
<sales person>
<appointment date>
<appointment status>
Now, the appointment status can be either 'kept', 'cancelled by customer', or 'cancelled by sales person' (for simplicity). I want to calculate the percentage that were cancelled. To calculate that, I will need to select all of the appointments, and divide the number that was not kept by the total number. Okay, I get that.
Now, the trouble is that I also want to show the appointments that were cancelled in my report, and exclude the appointments that were kept. In other words, I pretty much just want to skip printing these irrelevant records. How can I accomplish this?
formula1
If {<appointment status>} = "kept" then 1 else 0
That will give you a count which you can use to get your percentage for sales person.
if sum({#formula1},{<sales person>}) > 0
then sum({#formula1},{<sales person>}) % count({<appointment status>} ,{<sales person>})
else 0
Then suppress the details with a formula like this
{#formula1} = 1
I need your help in creating crystal report.
I have a formula in details section that computes working time.
How do I make the value return 0 if it is duplicated?
Here's the scenario
Name Time (Hours:Minutes)
John 1:20
........ 3:30
........ 3:30
Total Hours -> ?
My problem is I dont want to use the duplicated values (3:30) like shown above. I want a total hours for 4:50.
you have two options:
check the option in Database tab.. Select Distinct Records so that duplicate records will be eliminated.
If you don't want to use the first option then to calculate use Running Total so that you sum only those that are distinct...
Create running total something like Do sum only after change of time value
You can use the function "previous" to compare the current value with the previous value, but it works only with fields.
But i am not sure if i understood, you may be more precise about your question.
1) make a formula called "hours" or some other name
if not isnull(previous({Result.Time}) and {Result.Time} = previous({Result.Time}
then 0
else {Result.Time} /* you have to assure the same return type */
2) let the "total hours" be a sum of the formula "hours"
Note that it will work only if the rows are ordered by hours.
The result is the same of using a running total fields as purposed by Siva.