Pretty new to Stack overflow but hoping to get an answer to one of my project work
Region Sales Sales (LOD calculation only)
West 100 0
East 50 -50
North 200 100
What would the LOD calculation be to get 0,-50 and 100 in column Sales (LOD calculation only)?
I do understand that row 2 and row 3 are both subtracted from first row. It's easy to do with Table calculation but i am unable to figure the LOD part out
Welcome to Stack Overflow, i am also very new so hope i am helpful.
Looking at your requirement, i believe a LOD expression would not be valid for this. As you have mentioned you are already able to get your results using table calculations, which is the right approach for this type of problem.
LOD expressions are used when you need to do some aggregation in your data which is at a different grain then the selected dimensions.
Hope this helps.
To get sales like the one you displayed, to embed an if statement in an LOD calculation and subtract the initial sales from that number. You could write it as one big calc, but I'll break it down for simplicity.
You'll need a way to assign the amount for the western region to every row.
That calculation is
{EXCLUDE[Region]:SUM(IF [Region]='West' THEN [Amount] END)}
Then you subtract the initial sales with a field like this
SUM([Sales])-SUM({EXCLUDE[Region]:SUM(IF [Region]='West' THEN [Amount] END)})
Related
I get this problem often where I have a LOD calculation but instead of a single total value, I get the high and lows of the data range.
Here is my LOD calc:
But, the numbers it displays is a range of the lowest value to the highest value. I do not understand this. I have this problem often.
The way I tend to deal with this situation is to wrap the calculation in WINDOW_SUM().
WINDOW_SUM(SUM([LOD Period Demand]))
Put the window_sum calc on the Detail shelf, where you'll be able to add it to the title for your summary.
If i interpret it correct, then your DemandSalesNet is at the level of Site, Whse and Period. Means unique on these three variables. Correct?
Try Using "Fixed" instead of using "Include".
I hope that will work.
I have a pivot table with a dimension of 'companyname', column of 'month' and a measure of SUM(number_of_sales).
I want to change the measure expression so each column shows the number of sales minus the number of sales in the previous month, so sort if the opposite of a cumulative, the idea being to show how the number of sales per month has increased month on month.
How would i go about this, i'm not even sure where to begin?
Was thinking maybe something like
SUM(IF(column=column(1),number_of_sales,IF(Column()=column(2),
But im having no luck.
Is anyone able to point me in the right direction?
Thanks!
Try to use Above function:
SUM(number_of_sales) - (Above(Sum(number_of_sales),1,1)).
I have a dataset of Facebook posts with count of engagements and total reach for each post, for a list of markets and dates.
As part of the work I have defined engagement rate as a calculated field = SUM(engagements)/SUM(reach).
Now I want to produce a table showing for each market what is the difference in engagement rate respect to the average engagement rate of all the markets in the view (as a benchmark).
I have tried to use Fixed LOD expressions to achieve this, but I cannot make it work. The fixed value across all markets included in the filter does not correspond to the average of all the markets in the view. It's not even the sum of the market engagement rates, it's a number that I have no idea where is coming from.
To test the Fixed LOD expressions I tried using it with the row engagements metric (as well as reach and Number of Records) and the Fixed LOD expressions returns the sum of the engagements for all markets, as expected.
I'm not sure how to get the average of the markets average engagement rates. Unfortunately I cannot share the data as it is client sensitive.
This is the test LOD that works as expected:
{FIXED [Emea+Emea_Importers], [Platform], [Categories EMEA Brief], [Date in range]: SUM([Engagements])}
while this one is the one that I need, but that unfortunately doesn't work:
{FIXED [Emea+Emea_Importers], [Platform], [Categories EMEA Brief], [Date in range]: SUM([Engagements])/SUM([Reach])}
I have also tried the below, based on this answer
{FIXED : AVG( {FIXED [Emea+Emea_Importers], [Platform], [Categories EMEA Brief], [Date in range]: SUM([Engagements])/SUM([Reach])})}
but again the result is not correct.
If anyone can help that would be great.
What you are going to want to do is create an engagement rate calculation for each market like:
SUM({ INCLUDE [MarketName]: SUM(Engagement) / SUM(Reach) })
To get the get the overall average you can use a LOD such as:
SUM({ EXCLUDE MarketName: SUM(Engagement) / SUM(Reach) })
Then you should be able to create separate calculations for the difference, like:
[Engagement Rate - Market Excluded] - [Engagement Rate - Market Included]
Your table will end up looking like this:
I used the Sample SuperStore data for the example above.
Hope this helps!
I am a very basic user of tableau and I have not found an answer to my question.
I have a txt file that has historical daily data for 98% of all the stocks in the US, with their daily capitalization. Each stocks has its TICKER, Daily Market Value for every trading day of the year, and its SECTOR.
I did a simple time series that display SUM([Mktval]) (sum of all individual market values) across all stocks, on a daily daily, and where I can see that the total value as of 2016 is about 24 Trillion USD, as in the image below.
When I change the view column from DAY to YEAR, I don't see the right values, but something a lot larger. So I realized that I need to do SUM([Mktval])/252 to get the right value for a year (there are 252 trading days in a year).
If I change the view to MONTH, as in the chart below, the numbers are again wrong because 252 is not the right value to use in the division.
Is there any way that Tableau can adjust the values automatically to reflect the AVG MktVal across different time intervals?
Thanks
Replace SUM(Mktval) on the Rows shelf with the following calculated field
avg({ fixed day(Date1) : sum(Mktval) })
That solution is all in one step. It is perhaps a bit more clear to use 2 steps. First, create a calculated field called total_daily_market_value defined as
{ fixed day(Date1) : sum(Mktval) }
Then make sure that calculated field is a measure. It is an LOD calculation that you can think of as a separate table with one value for each day showing the total market value for that day.
Drag that measure to a shelf, and then change the aggregation function to AVG(), MEDIAN(), MIN(), MAX() or STDEV() as desired. Tableau will aggregate the total_daily_market_value using your chosen aggregation function for whatever values of Date1 are in your view.
I have a problem with calculating CPC in Tableau.
I have the cost and the number of the click but Tableau is not calculating the right CPC. the formula I used : [Cost]/[Click]
I attached two tables in this request. first shows the table which I calculated all KPIs in Zeppelin. the second the calculation in Tableau.
The whole data set has many null and 0 values, but it is the same data set used in zeppelin.
May I ask for help,how to solve this issue?
The result of CPC is not correct in Tableau.
Helena,
the issue is that Tableau is using aggregate functions when you add measures, and in this case of CPC calculation, it's not correct.
Tableau is doing [cost]/[click] division (on row-level) and then simply averages all those numbers (you are basically calculating an average of an already average number).
What you are after is a bit different and you have to fix the math to make sure all costs are aggregated first and then divided by sum of all clicks, so:
SUM([cost]) / SUM([clicks])
This will give you the correct and mathematically sound numbers.
Hope this helps.
SUM([cost]) / SUM([clicks]) will resolve the issue