How to create different numerical ranges in the same view in Tableau? - tableau-api

Lets say I have a dozen companies and their amount of revenue. How could I visualise it so that I can show in one view - companies with below 10 million in revenue, companies with between 10m - 100m in revenue, and companies with 100m+ in revenue? Would I somehow use something like Bins or Sets to do this? If anyone could set me along the right lines, this would be appreciated.

Related

Campaign analysis in Tableau

I am doing campaign analysis and the objective of campaigns is to convert lead into customer. I want to see how many leads are exposed to how many campaigns in terms of percentages before they convert to customer.
Below is the sample data where there are four unique lead.
abc has seen three campaigns, efg has seen two campaigns and so on and so forth
I want to show in pie chart may be something like below in tableau where out of 4 leads 2 leads has seen 1 campaign each so 50%, 1 lead has seen 2 campaigns so 25% and 1 lead has seen 3 campaign so another 25%
First of all you have to find how many campaigns have been exposed for each Lead, Count Campaign:
{ FIXED [Lead id] : COUNT([Campaign])}
Since you want to breakdown your pie with this value, you need to convert this calculated field into a dimension.
In order to calculate the % you're looking for, you need just an additional step; Metric:
COUNTD([Lead id]) / attr({ FIXED : COUNTD([Lead id])})
Doing so you're going to compare each value to the total distinct value of your Lead (4)

Tableau calculated measure using previous months

I have the following data table:
Month Accounts Sales
Jan-19 50 5000
Feb-19 60 6000
Mar-19 70 7000
Apr-19 80 8000
May-19 90 9000
I am trying to create a new measure which will return the sum of 3 months of sales / Sum of 1st month Accounts.
For e.g.
for Mar-19 the value should be (Jan+Feb+Mar'19 Sales)/Jan-19 Accounts i.e. (18000/50)
for Apr-19 the value should be (Feb+Mar+Apr'19 Sales)/Feb-19 Accounts i.e. (21000/60)
for May-19 the value should be (Mar+Apr+May'19 Sales)/Mar-19 Accounts i.e. (25000/70)
.......
and so on...
Was wondering can a DATEDIFF or some table calculation could be use to achieve the above?
Best Regards
Table calculations are well suited for this. They take a little time to understand but are very useful. Start with the online help. Make sure you understand partitioning and addressing.
The functions that will be useful are Window_Sum() and Lookup()
An example calculation could be
WINDOW_SUM(Sum([Sales]),-2,0) / LOOKUP(Sum([Sales],-2))
The -2 and 0 are offsets from the current position
Note, for table calcs, the formula is only part of the definition of the calculation. You need to edit the table calc to set the partitioning and addressing (aka compute using) to tell Tableau how to arrange the data before evaluating the table calc.
Tableau will take a guess for partitioning based on how your viz is arranged, and the guess is often right, but it is usually best to specify the specific dimensions for partitioning. See the help pages on table calcs.

Custom aggregation in Tableau when joining two different types of tables

I'm fairly new to Tableau, but otherwise pretty well versed in data and SQL, etc.
I'm working on a dashboard that will display some financial data. The two main categories are "Actual" results and "Plan" (or budget).
The Actual results are at the individual transaction level by cost center and by account. The Plan is at the cost center and account level. For example:
Actual table:
Cost Center | Account | Amount
______________________________
ABC 10023 500
ABC 10023 600
BAC 10023 250
BAC 10023 300
Plan table:
Cost Center | Account | Plan Amount
___________________________________
ABC 10023 2000
BAC 10023 2300
When joining these two tables together in Tableau, the Plan Amount gets repeated at the transaction level (obviously, as it's a straightforward LEFT JOIN), which in this example for Cost Center ABC would aggregate to a total of 4000, and for BAC it would aggregate to a total of 4600.
What I'm hoping to somehow accomplish is for the Plan Amount to only be aggregated at the cost center level, not at the transaction level. In the actual tables I'm using, the Cost Center rolls up through a department hierarchy, i.e. a department can have multiple cost centers, etc, and when I show results at a department or division level it really blows up the Plan Amount numbers, they're vastly overstated.
Is there some way to accomplish this in Tableau? In SQL I'd probably use a window function of some sort to divide the Plan Amount by # of transactions per Cost Center so that it would aggregate correctly (though this would lead to some rounding errors, but not that material). But don't know how to do this in Tableau.
When joining it will be put against the transaction level, as with any normal inner join. Therefore you have options on how to handle this.
You could do it using an aggregation - i.e. instead of SUM you could MIN / MAX / AVG the field, which would always return the same value.
Alternatively you could blend this data, rather than join. If you blend in the visualisation layer and only blend it when showing the Cost Centre level, this will prevent aggregating against all transactions. To blend this would be a completely separate data source. It would "blend join" in Tableau - see Data - Edit Blend Relationships in Tableau.

Qliksense: Compute median of grouped data

I'm facing an issue in QlikSense, trying to compute some statistical indicators (Percentiles, Quartiles, StdDev, Median etc.) on a dataset which is already grouped by the source.
I mean that my dataset is something similar to the following, in which I have for each combination of Week and Customer Age the total number of purchases:
I want to show the median of Customer Age, and due to the structure of the dataset I can't use fractile or median built-in functions, since they would come out with something different.
Let's suppose I want to calculate the median age of people for all the 3 weeks, so that I want to know what's the age of people who have done the 50% of my purchases.
To let you better understand the question, I show you the histogram:
In this case, the median I want to get is 24-26 years, since the 50% of the total population falls under that range.
I found a useful reference here, but I am having troubles in writing this formula in QlikSense
https://mba-lectures.com/statistics/descriptive-statistics/603/relationship-between-quartiles-decile...
Thanks a lot in advance.
[EDIT]: This is my Data Model View:
[EDIT 2]: Here is my qvf with a dataset more similar to the original one I'm using. As you can see, I can't get the correct result using your formula. In addition, I would like to use it in order to plot the trend of the median through weeks, but it doesn't seem to be possible (Even if I use the modified version of the formula I pointed out in the comments).
If you want to calculate median in such a scenario you need to weighted median and basically check which dimension value is in the middle:
Aggr(
If(
(Rangesum(
Above([# Purchases],0,RowNo())
)
/Sum(TOTAL [# Purchases]))>=0.5
and
(Rangesum(
Above([# Purchases],1,RowNo()-1))
/Sum(TOTAL [# Purchases]))<0.5
,[Customer Age])
,[Customer Age])

Income, Expenditure, EBIT Visualization in Tableau

Could any one please suggest the best way to visualize Income, Expenditure and EBIT numbers for 5 Business Units? Thanks in advance
At our company, I use a dual-axis bar chart to represent this.
Total sales is in orange and the EBIT in blue.
This shows how each branch compares with one another in terms of sales and EBIT, and also shows how much of sales makes it to EBIT at each branch.