I have a field, which takes values less than zero & greater than zero.
Also in that field, Values will be having leading zeros.
So I have used the following conditions like
Replace({Command. Field}, "0",".") and
If {Command. Field} < 0
then ((Int(tonumber({command. Field}))) *1000)
When I save the formula getting error like "A Boolean is required here"
Why I am getting this error?
Since this field has values less than zero & I want to automatically multiple that value with 1000 to get the desired output.
Is it possible to give both of the conditions in single formula?
Related
On one sheet, I have account code and in the cell next to it, I need to look up the account code on the next sheet to average the cost excluding those cells that are zero in col. b from the average calculation.
The answer for London should be: £496.33 but having tried various sumifs / countifs I cannot get it to work.
You probably need COUNTIFS which -- similar to the SUMIFS you are already using -- allows to define multiple critera and ranges.
So, if the column R contains the values, you want to build the average upon, and the column H in the respective row must equal $B$28 to be included in the sum, the respective COUNTIFS looks as follows
=SUMIFS('ESL Info'!$R:$R,'ESL Info'!H:H,$B$28)/COUNTIFS('ESL Info'!$H:$H,$B$28, 'ESL Info'!$R:$R, "<>0")
ie additionally to the value in the H-column to equal B28 it also requires the value R-column (ie the actual number you are summing up) to be different from 0
You could also add the same criteria 'ESL Info'!$R:$R, "<>0" to your SUMIFS, but that isn't necessary, because a 0 doesn't provide anything to you sum, thus it doesn't matter if it's included in the sum or not ...
And depending on the Excel version you are using, you may even have the AVERAGEIFS function available, which does exactly what you want
=AVERAGEIFS('ESL Info'!$R:$R,'ESL Info'!$H:$H;$B$28,'ESL Info'!$R:$R,"<>0")
I created a report that compares two amounts and shows its increase or decrease percentage.
logic is
amount1 compared to amount2 then lastly show its % inc/dec
I have this field than computes for the increase/decrease of the number
formula is
(tonumber({tblReclass.Amount})/tonumber({tblReclass.AverageAmt}))*100-100
however there are data rows that contain zero values and zero division throws an error so I decided to put an if statement and the code is now this
if {tblReclass.Amount} > 0 and {tblReclass.AverageAmt} > 0 then
(tonumber({tblReclass.Amount})/tonumber({tblReclass.AverageAmt}))*100-100
else
0
it now throws an error after the then statement it says
a string is required here
what must be revised in the code
The computation works fine if I remove the zero values
so what I did temporarily was remove the zero data values but this report now shows incomplete data. I want to show the zero values
Try this version:
if tonumber({tblReclass.AverageAmt}) > 0 then
(tonumber({tblReclass.Amount})/tonumber({tblReclass.AverageAmt}))*100-100
else 0
I am trying to create a chart in tableau which will show me the comparison in weeks, i.e. the comparison between the trend from week 1 to week 5.
In simple terms it should be like:
If Verdict = "Not Reversing" THEN count the total number of Verdicts
Else do not count
If IF [Verdict] = "Not Reversing"
THEN
COUNT([Verdict])
END
IF [Verdict] = "Not Reversing"
THEN
COUNT([Verdict])
END
Error message shows cannot mix aggregate and non aggregate functions
Assuming your data source has exactly one data row per verdict ... (Always be clear about what one row in your data source represents.)
You could define a calculated field called Number of Non Reversing Verdicts defined as INT([Verdict] = "Non Reversing") That field will have the value 1 for Non Reversing verdicts and 0 otherwise. The INT() function converts its arguments into an integer, and treats TRUE as 1 and FALSE as 0.
You can then plot SUM([Number of Non Reversing Verdicts]) as desired, along with SUM([Number of Records]) to see the total number of verdicts -- or even compute the ratio of the two formatted as a percentage.
For extra credit, you could rename the predefined field [Number of Records] to [Number of Verdicts] for this data source if that helps make it more clear. (BTW, look at the definition of [Number of Records] and make sure you understand why that works)
I have a csv-file with some integers stored in three columns
trainData = load('training.csv')
I want to count the occurences of a certain value within a certain range and plot the results.
count = #(x) (sum(trainData(:,2)==x));
fplot(count,[0,500]);
However this only works for certain limits and I can't figure out why. If the limits are not set "right", count() always returns zero.
this works, meaning the plot shows some values > 0:
fplot(count,[0,500]);
fplot(count,[100,600]);
fplot(count,[101, 601]);
fplot(count,[200,700]);
fplot(count,[50, 550]);
The plot of [0,500]:
This does not, meaning the line stays flat, even though there are definitely some y > 0 within this range (compare to previous plot):
fplot(count,[0,300]);
fplot(count,[200,450]);
fplot(count,[1,501]);
The plot of [200, 450], oddly the value for f(250) is 1 and the rest is 0 :
The reason for this strange behaviour was fplot's way of picking values from the specified range of x-values. By default the step size is not 1 (which I assumed), nor does fplot use all possible values within the specified range (which would be probably impossible). Therefore my method did not find all values occuring in the csv (they were all integers). So the "working" examples from above did probably only hit some of the occuring values and the non-working example simply the starting value (plot of [200,450]), but not any other.
Briefly speaking, following solves the problem:
fplot(count,[0,n], n);
It evaluates the anonymous function for each integer in range 0 to n.
i have forecast bias values being displayed as percentages and i want to color those values based on certain thresholds like it should be RED if its value greater than 100% and less than -100% and green if between -99% to 99 % so i created a calculated field as
If [Forecast Bias] >= 100 THEN "Red"
elseif [Forecast Bias] <= -100 THEN "Red"
elseif [Forecast Bias] > -100 THEN "Green"
END
but i am getting some color field as Nul and wrong color on the values.I feel its taking actual values of forecast bias rather than percentage value for comparison.
Assuming you want to separate data rows based on their value for the [Forcecast Bias] field and treat rows separately depending on whether the value of [Forecast Bias] is within your range, then I suggest creating the following calculated field, called, say, "Bias_in_Range".
abs([Forecast Bias]) < 100
This defines a boolean valued dimension calculated field.
You can then place this field on the Color shelf to partition data according to that dimension.
To make the color legend more readable, you can create aliases for the dimension members, True and False in this case, to display labels like "In Range" and "Out of Range" to get readable color legend.
You could replace the hard coded 100 with a parameter, say "Bias Threshold", and show the parameter control to allow users to adjust the threshold dynamically.
abs([Forecast Bias]) < [Bias Threshold]
You will see null values for this field only for data rows that have a null value for [Forecast Bias]. If you don't like that, you have the choice of:
filtering out nulls,
fixing the source data to supply the missing field values, or
adjusting the definition of your calculated field to
treat the rows with null [Forcecast Bias] as either in range or out of range as you prefer, using a function like isNull() to test for null values
I can't speak to why you may see the wrong color without seeing more info about your data