Tableau aggregate functions returning wrong values - tableau-api

I'm trying to calculate the sum of Impressions and Clicks by AdGroupId in Tableau. Tableau is returning wrong values of summation for several AdGroupIds although the underlying data seems to be perfectly fine.
Refer attached images - the sum of impressions and clicks for the given AdGroupId is clearly wrong.
Can anyone point out the issue or suggest what can be done in this case?

Before building a view, convert AdGroupId to dimension. From your screenshot it is clear that the field is a measure.
Ids are sometimes stored as numbers. Tableau automatically convert numbers to measure. But i don't think there will ever be need to calculate sum(id) or average of id.
Count you can calculate from dimensions too. It is therefore advisable to convert these type of dimension fields to dimension/string data type at the time of importing the data in Tableau. Hope this clarifies

Related

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])

How to sort by any measure in a Tableau table

I've built a new worksheet that has two dimensions and several facts. When I try to sort on any column, it only seems to sort within the dimensions. Is it possible to sort based on the column, ignoring dimensions? I find if I concatenate the two dimensions into one... that does work, but is not ideal.
Ah yes, sorting in Tableau. Took me a long time to understand it. It doesn't do sorting the way you would expect in other tools like Excel. This is because it's grouping dimensions from left to right. Think of each dimension getting nested inside the one to the left of it. Another way to think of it is that Tableau doesn't sort measures, it sorts dimensions based on some value a measure. That's why concatenating dimensions will yield the expected result, because you have just one calculated dimension and that dimension gets sorted by the value of a measure. You can right click on the concatenated dimension in your Rows shelf and choose Show Header. That's probably your best bet.
See this article from The Information Lab on the sorting in Tableau: https://www.theinformationlab.co.uk/2014/11/03/understanding-sorting-tableau/
There are some Tableau Community posts about it too.
https://community.tableau.com/thread/118958
https://community.tableau.com/thread/221956
https://community.tableau.com/thread/164714

How to avoid aggregation of measure values in tableau

I'm trying to retrieve and analyze records from SQL server. Whenever I drag the measure values to rows field it gets auto aggregating itself in tableau.
I dont want this aggregation to be done since my values doesn't make sense when it gets agregated.
Is there a solution to remove this aggregation in tableau ?
Thanks
Yes, you can avoid aggregating values. However, your problem isn't that you are aggregating your values, your problem is that you are treating dimensions as measures.
To fix this you can convert Year from a measure to a dimension:
Of course, if you want to disaggregate the measures then you can always do that too:

Tableau CPC calculation

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

Different Aggregation calculations of a measure using two dimensions in Tableau

It is a Tableau 8.3 Desktop Edition question.
I am trying to aggregate data using two different dimensions. So, I want to aggregate twice: first I want to sum over all the rows and then multiply the results in a cummulative manner (so I can build a graph). How do I do that? Ok, too vague, here follow some more details:
I have a set of historical data. The columns are the date, the rows are the categories.
Easy part: I would like to sum all the rows.
Hard part: Given this those summations I want to build a graph that for each date it shows the product of all the summations from the earlier date till this date.
In another words:
Take the sum of all rows, call it x_i, where i is the date.
For each date i find y_i such that y_i = x_0 * x_1 * ... * x_i (if there is missing data, consider it to be one)
Then show a line graph for the y values versus the date.
I have searched for a solution for this and tried to figure it out by myself, but failed.
Thank you very much for your time and help :)
You need n calculated fields (number of columns you have), and manually do the calculation you need:
y_i = sum(field0)*sum(field1)
Basically because you cannot iterate on columns. For tableau, each column represent a different dimension or measure. So it won't consider that there is a logic order among them, meaning, it won't assume that column A comes before column B. It will assume A and B are different things.
Tableau works better with tables organized as databases. So if you have year columns, you should reorganize your data, eliminate all those columns and create a single field called 'Date', which will identify the value of your measure for that date. Yes, you will have less columns but far more rows. But Tableau works better this way (for very good reasons).
Tableau 9.0 allows you to do that directly. I only watched a demo (it was launched yesterday), but I understand that now there is an option to selected those columns (in the Data Connection tab) and convert them to a database format.
With that done, you can use a PREVIOUS_VALUE function to help you. I'm not with Tableau right now. As soon as I get to it I'll update this with the final answer . Unless you take the lead and discover yourself before that ;)