Tableau graph average and sum - graph

I have transactional data for a sales team showing the transaction amount per transaction, the sales person for that transaction, his team and his salary. Every row denotes a unique transaction (please refer image). I need to make a team-level graph which shows the correlation between the salary they are paid and the revenue they generate for the company i.e. a simple stacked bar chart with salesTeam name on X axis and amounts on the y axis with every bar representing the total salary and total revenue(Amount) for a team.
In the example I've highlighted team 'Central', for which the salary paid is 25k (10k for salesperson A + 15k for salesperson B) and the revenue they make for the company is 430k. Please note that the salaries for some salespersons may be missing (eg. for E). The issue I'm facing is that sum(Salary) adds up the salaries for every row, so for salesperson A it becomes 20k instead of 10k. I tried avg(Salary) but that doesn't work as Tableau calculates the average for the entire column instead of average per salesperson. How can I solve this issue?
Thanks

Here you have a level of detail problem. Basically, Tableau will calculate a formula at the level of detail of the visualisation, so if salesperson is not in your view it will roll up the equation to calculate at the highest level. This is great when you want a dynamic calculation but that doesn't sound like what you are trying to achieve.
Your best option would be to aggregate the data into Tableau so you only have 1 line per sales person with a total of their revenue for all transactions. This would avoid the complexity of the calculated field (and make Tableau perform better).
However, if this is not possible the good news is the answer is a Level of Detail expression (i recommend doing some reading on this if you havent come across before). Basically, you tell Tableau at what level you want the calculation at.
If I understand you want to calculate the ratio of transaction amount and salary paid for each team.
So create a calculated field as follows:
{ FIXED [Team]
: sum(([Amount]))/
(sum({ FIXED [Sales person]:
AVG([Salary])}))
}
What this does is calculates for each team the ratio between the amount and the salary. The use of the second fixed equation that is nested within it (Salesperson) ensures that the salary is not summed for the number of transactions of a salesperson.
Using this I got a result of 17.2 for Central. Is this what you would expect? Do you need a way to account for salaries that are not known?

Related

How to calculate fare

like Ola, Uber etc. how they calculate fare
Example when I start from one point to another (like 1 to 2km) shows amount that is 40 rs
how they calculate use map distance in code or something else in code can u please explain how it work? Simply how it works fare system works?
This is lifted directly from the Uber website:
Many data points go into calculating an upfront price, including the
estimated trip time, distance from origin to destination, time of day,
route, and demand patterns. It also includes tolls, taxes, surcharges,
and fees (with the exception of wait time fees).
Some cities do not provide upfront prices. Instead, you’re charged
either a minimum price or a price based on the time and distance for
your trip’s route, which may include a base fare, a Booking Fee,
surcharges, tolls, and dynamic pricing. Prices may vary by location,
the vehicle option you select, and other factors.
So it sounds like a combination of any relevant data points your app is able to collect and that you feel should be considered billable are applied to the calculation. I imagine you would want to use the map distance rather than a predefined route in case of detours, traffic, etc.

mdx SSAS - how to - change calculation depending on dimensions viewed

i am hoping you can improve the 'love' side of my love-hate relationship with MDX.
so, say i have a cube of sales with dimensions customer, year, month, week, product. i have calculated measure based on certain customer values. that is, the calculation is based on sales for customer X in month Y, and then other customers (same calc, maybe different month, etc), added together. basically, these are 'key' customers that have been identified as leading indicators, and the calculated measure is needed for other comparisons as a measure.
now, when i do analysis by year, month, or customer, all is great. the numbers look good and the calculation is doing what i want it to.
however, when i do analysis by week or product, this calculation presents numbers that, at first, don't look sane. i have researched the math, and I understand why it's showing what it is. not all products sell every month to all customers, or each week, etc.
so, what i would like to do in the case of say, analysis first by month, then by week or product, is show the month value as if there were no further breakout by product (or week), just the same calculation value as if the analysis "stopped" at the month level.
i have researched the mdx function reference and found some ideas, but testing has thus far provided nothing useful, so i'm not even sure i'm conceptualizing the problem correctly. i'm hoping someone can point me to the correct function or syntax, and give me an example as a starting point.
if there is any info missing, let me know and I will be happy to clarify or add to my question.
Danylo was correct. i was looking for an All() (function) when i needed the All member.
here is what worked:
sum(
(
[Time].[Week].[All],
[Product].[Product Number].[All],
[Time].[Month].[All].[Y],
[Customers].[Customers].[All].[X]
),Measures.[Sales]
)
+ ... repeat ....
Thanks for the help!!

dimensional data modelling design - Data warehouse

I am having
dimension tables
item (item_id,name,category)
Store(store_id,location,region,city)
Date(date_id,day,month,quarter)
customer(customer_id,name,address,member_card)
fact tables
Sales(item_id,store_id,date_id,customer_id,unit_sold,cost)
My question is if I want to find average sales of a location for a month Should I add average_sales column in fact table and if i want to find sales done using the membership card should I add corresponding field in fact table?
My understanding so far is only countable measures should be in fact table so I guess membership_card should not come in fact table.
Please let me know if I am wrong.
No, you should not add an average sales column to your fact table, it is a calculated value, and is not at the same "grain" as the fact table.
Your sales fact table should be as granular as possible, so it should really be sales_order_line_items, one row per sales order line item.
You want to calculate the average sales of a given store for a given month...?
First, by "sales" do you mean "revenue" (total dollars in) or "quantity sold"?
Average daily revenue?
Average monthly revenue, by month?
If you have the store id, date, quantity sold (per line item) and unit price, then it's pretty easy to figure out.
You Should not add aggregate columns In the same fact table. The measures in the fact table should be at the same grain. So if you want aggregate metrics, build a separate fact table at the required grain.
So, I might have a fact aggregate table named F_LOC_MON_AGG which has the measures aggregated at location and month level.
If you do not have aggregate tables, modern business intelligence tools such as OBIEE can do the aggregation at run time.
Vijay

Calculation of Cost Amount Physical

How does AX calculate the Cost Amount Physical on inventory transactions (Inventrans table)?
When posting packing slip in purchase order, transaction records are created in the Inventrans table, this table has a field (CostAmountPhysical)
How does AX calculate the value of this field?
Sometimes this value is different to the net amount calculated in each item of the purchase order?
The CostAmountPhysical field is calculated in the InventMovement.updateLedgerPhysical method.
There is no easy explanation of how and why it is calculated. Go and have look in the code.
Please update you cross reference, this simplifies questions like this one enormously.

Confusion over Google Analytics (GA) Absolute Unique Visitors data

GA Unique Visitors data isn't making sense to me. From the GA FAQ we get the following definition for 'Visits vs. Visitors'
"The initial session by a user during any given date range is considered to be an additional visit and an additional visitor. Any future sessions from the same user during the selected time period are counted as additional visits, but not as additional visitors. "
The part that I can't resolve with the GA graph is "Any future sessions from the same user during the selected time period are counted as additional visits, but not as additional visitors". For the graph below covering a 30-day period, I would understand the GA definition to mean that the data represents uniqueness across all 30 days, right? But if you look at the screen shot below, you see a regular pattern for each week over the 30-day period the report covers. From that, it seems the numbers we are seeing associated with each of the days of the graph (e.g. 3.92% (4142) for Tuesday, September 8) is a count of unique visitors just in the context of that one day - i.e. without correlating their uniqueness to the rest of the days in the 30-day period. If the graph actually showed uniqueness across the 30-day period, I would expect the daily numbers to start high in the early days of the period and decrease over the 30-day period as the number of already-seen visitors (i.e. returning visitors) increases, no?
What am I missing here?
UPDATE
Helpful clue from Jonathan S. below got me on the right track.
I think I understand now what the daily bar graph values mean, but it's a little counter-intuitive and I'd bet not what some others might be assuming as well. The reports states "39,822 Absolute Unique Visitors" at the top, which means just that: over the 30-day period we saw this many uniques. Fair enough. The confusing part is that the daily (or weekly) bar values in the graph below are not mutually exclusive uniques as I had assumed, but are values relative only to the 39,822 total - i.e. there is overlap between the unique visitor counts across any group of days. This means the sum of the daily % values > 100% and the sum of the daily count values > 39,822. The algorithm is: when you visit for the first time in the 30-day period, call that "today", you add 1 to the total (39,822) and 1 to the "today" bar value. When you show up again "tomorrow", you are NOT counted again in the total, but ARE counted as 1 in the "tomorrow" bar value.
alt text http://img.skitch.com/20090922-djti81ejj5gqn575ibf8cj1e8x.jpg
I believe it's just an issue of grouping. The top right of the graph has 3 icons to group by day, week, or month. It's currently grouping by day. So if I visit your site today and come back tomorrow, I'll be counted once for each day.
I tried looking at the month view for one of my sites but it didn't give me much meaningful data. I believe the above should answer your original confusion though.
Is it possible that you're searching for something what isn't existing anymore? Unique Visitors/Visits is old terminology. Check: https://www.seroundtable.com/google-analytics-sessions-users-18424.html
Then check how sessions and users are defined:
Sessions ("ex-visits", it's very detailed): https://support.google.com/analytics/answer/2731565?hl=en&ref_topic=1012046
Users in Google Analytics reporting are defined as "Users who have initiated at least one session during the date range". So IMHO it's not about 30 days, it's about the SELECTED date range.
I hope this helps.

Resources