Tableau calculation with attributes - tableau-api

I'm new with tableau and I try to calculate with different attributes from one dimension and one measure.
I want to calculate the sum of the attributes RC,RD and RP and divide this by RI. I would be very thankfull if you can help me.

Create two calculated fields.
if [Rrid] = 'RC' or [Rrid] = 'RD' or [Rrid] = 'RP' then [Rrem] end
Then create the same for RI. Divide the first by the second
sum(calc1) / sum(calc2)

Related

Tableau: Calculate the average value for the last 3 records

I have a time series data fro the different products. i like to calculate the average for each products based on only last 3 values. can you please help me.
Thanks
Kathir
Use SIZE() - INDEX() + 1
Drag it to your row or column and convert as discrete. Use table calc if needed
Now you will have an index for each row. Create another calculated field which will be using fix LOD of the above calculated field and when Index = 1 or 2 or 3, it sums it
You will be able to calculate average by diving the field with the sum of fix LOD created

DAX: Averaging multiple % Columns

I'm new to Power BI and Dax, having some difficulty with the below scenario.
test a b c d AVERAGE
aa 51.97% 46.61% 49%
I have 4 columns, a-d, and I simply want the average of the 4 columns in the AVERAGE column. Dependent on the row different columns may be blank. Each of the columns are measures pulling through a % value into the table.
I'm sure there must be a simple solution to this but any help would be much appreciated.
Try creating a column like this:
AVERAGE = ([a]+[b]+[c]+[d])/4
UPDATE: BLANK measures don't affect average result.
AVERAGE = DIVIDE(([a]+[b]+[c]+[d]),
(IF(ISBLANK([a]),0,1) + IF(ISBLANK([b]),0,1) +
IF(ISBLANK([c]),0,1) + IF(ISBLANK([d]),0,1)))

Tableau Average of "above average values"

Supposing I have many plots on a y-x axes. I want to calculate the average of all the curves/points above the “average curve” and the average of all the curves below the “average curve”.
I have created a measure that is the “average curve” using the following calculation:
AverageLF = AVG([LF])
I am trying to create a measure that would express the average of all the points above average using something some sort of conditional averaging like this:
AboveAverage = AVG ( IF [LF]>[AverageLF] THEN [LF] END )
Apparently I get the: "Cannot mix aggregate and non-aggregate arguments" calculation error.
I want to do the same with the median. (median of all the points above, median of all the points below the median)
I am relative new to TABLEAU and this is very important for my work, could you please advise?
Thanks
Correct me if I am wrong,
you want to check if the values in [LF] are > [AverageLF] if yes then take them aside and do an average of those values. is that correct?
If yes then do this,
AboveAverage = IF [LF]>[AverageLF] THEN [LF] END
Now you have a value AboveAverage which has list of all values > [AverageLF]
Now Create a calculated field,
Final = Avg(AboveAverage)
This should have average of all values AboveAverage.
Let me know if this works.

Matlab Loop of all combinations

Im new to Matlab and this seems to be beyond me. Appreciate the help and thanks in advance.
Basically, I have a multiple columns dataset with column headers. Column numbers could vary from dataset to dataset.
Need to iterate through all the combinations of columns (eg A+B, A+C....B+C, B+D...etc) and run a formula (in this instance it is a correlation formula but could be another formula subsequently).
If particular combination returns "true", then the column headers of the pair will be returned.
Would appreciate if you could point me in the right direction.
Thanks in advance.
Use nchoosek to get all pairs of columns:
pairs_columns = nchoosek(1:m, 2);
pairs = {};
for pair = 1:size(pairs_columns,1)
flag = your_correlation_test(data(:,pairs_columns(pair,1)), data(:,pairs_columns(pair,2)));
if flag
pairs{end+1,1} = data_header(pairs_columns(pair,1));
pairs{end,2} = data_header(pairs_columns(pair,2)); %// Note that you don't need end+1 anymore as the previous line will have already increased the number of rows in the vector
end
end
m is your number of columns
your_correlation_test is your test function that returns a Boolean result
data is your dataset (which I'm assuming you can index by column number?)
data_header is a place holder for whatever the correct way to get the header is from your dataset based on the column number. Sorry I'm not very familiar with datasets in Matlab

Interactive Report - aggregate sum of multiple columns from one table multiply by values from another Table

I have a challenge in Oracle Apex - I would to sum multiple columns to give 3 extra rows namely points, Score, %score. There are more columns but I'm only choosing a few for now.
Below is an example structure of my data:
Town | Sector | Outside| Inside |Available|Price
Roy-----Formal----0----------0----------1------0
Kobus --Formal----0 ---------0--------- 1------0
Wika ---Formal----0----------0--------- 1------0
Mevo----Formal----1----------1----------1------0
Hoch----Formal----1----------1----------1------1
Points------------2----------2----------5------1
Score------------10---------10---------10------10
%score-----------20---------20---------50------10
Each column has a constant weighting (which serves as a factor and it can change depending on the areas). In this case, the weighting for the areas are in the first row of the sector Formal:
Sector |Outside| Inside |Available|Price
Formal----1----------1 ----------1-----1
Informal--1----------0 ----------2-----1
I tried using the aggregate sum function in apex but it wont work because I need the factor in the other table. This is where my challenge began.
To compute the rows below the report
points = sum per column * weighting factor per column
Score = sum of no of shops visited (in this case its 5) * weighting factor per column
% score = points/Score * 100
The report should display as described above. With the new computed rows below.
I kindly ask anyone to assist me with this challenge as I have tried searching for solutions but haven't come across any.
Thanks a lot for your support in advance!!