Remove "?" from calculation field when exporting - filemaker

I have numerous calculation fields on my reports, and some have just a "?" instead of the calculated answer, whilst I'm not too bothered by this, it does annoy me when I export my reports and see "?" all over the spreadsheet.
My question is, what is the best way to get around this? Say I wanted to display "0" instead of "?" in my calculation fields, just to tidy up the report when exported. What would be the best way to do this? The calculations are quite complex so I struggled to add in an If statement to display 0 if the result is "?" and I obviously cannot do a find and replace on a calculation field.
Any suggestions/advice welcomed. Thankyou.

I am guessing that the reason why the formula:
Round ( Free Stock / Total Last 7 Days ; 1 )
returns an error is that the Total Last 7 Days field is either empty or evaluates to zero. To prevent such error, you could do:
If ( Total Last 7 Days ; Round ( Free Stock / Total Last 7 Days ; 1 ) )
which will return an empty result when the divisor is empty or zero.
To force a zero result in such case, you could do:
If ( Total Last 7 Days ; Round ( Free Stock / Total Last 7 Days ; 1 ) ; 0 )
but I don't think it's good practice to output artificial incorrect results.

Related

Reset Running Sum to Zero on encountering specific value in a column in Tableau

I have Student Attendance information Date-wise as if Attended on a particular day then the value is 0, if not then 1. I want to have a running sum that shows consecutively how many days a student has missed. So the running sum has to reset when it encounters 0. How I can achieve this in Tableau.
After so many trial and errors I finally got to this expression and it seems to be working fine after testing.
IF ATTR([Attended]) != 0
THEN IF FIRST() = 0 # This IF is basically for the first value to be displayed as 1 instead of 2 (1 + 1)
THEN 1
ELSE SUM([Attended])+PREVIOUS_VALUE(SUM([Attended]))
END
ELSE SUM([Attended])-SUM([Attended]) # Reset on 0
END
There might be a simpler logic, but this is working for me.
Hope it works for others too(make sure to delete the Comments in the expression if used in Tableau!!!)

Summing a formula containing a running total in Crystal 10

I have searched on other questions similar to this but none seem to be in the same situation.
I have a series of transactions in which I am using a running total named TranNumber which resets on the change of the account number. When I sort by descending transaction date this running total gives me the most recent transaction as 1.
I also have another formula which contains a list of transaction codes and their position on a workflow (done using a select case formula).
I have tried to sum the following formula as well as variations such as using variables and passing data into a sub report and back to 'trick' the software into not seeing it as a running total, still to no avail as I can then not sum a variable.
if {#TranNumber} = 1 then
if {#ProcCode} startswith "1 - " then 1 else 0
Ultimately I want a count of accounts in each position on the workflow to then put into a graphical form.
If anyone has tried to do this successfully or can suggest a way to only bring back the most recent transactions for each account to avoid having to use the above method it would be greatly appreciated :)
Thanks in Advance
Resolved this issue by using the formula above and assigning to a variable and placing a counter formula in the details which worked like the below
shared numbervar x;
If {#TranNumber} = 1 then
if {#ProcCode} startswith "1 - " then x := x + 1
I then placed this formula in the details and then simply output the variable in the report footer which gave me the number I was looking for.

How to sum a calculated a field on top of another calculated field?

The current issue I have maybe a bit difficult to describe but I will do my best.
Currently, in my workbook, I am experiencing duplicates at the product level so I created a calculated field to work around that. I wanted to know which individual products have not been quoted the past year so the answer should be 1 for not quoted and 0 for quoted, I worked around that by doing an if statement with % products not quoted the formula looks as such:
IF [% Not Quoted] > 0
then 1
else 0
end
which I named Prod Not Quoted. That worked great for me,
however now I want do the count or sum(?) of products not quoted at the vendor level which would mean my products not quoted needs to be grouped by the vendor name. To be specific my objective is to provide a table of all products not quoted by vendor name without duplicates at the product level. What I tried to do is create a new calculated field using the previously which I calculated as the following:
IF [Prod Not Quoted] = 1
then sum(1)
else 0
end
The latter calculation, however, gave me the sum of all products quoted and not quoted along with the duplicates I am trying to avoid. Why would IF [prod Not Quoted] = 1 then sum(1) else 0 end not work?
Someone on tableau forum with the following suggestion
SUM (IF [Prod Not Quoted] = 1 THEN 1 ELSE 0 END)
however I got the error cannot sum something that is not already aggregated.
Is there any kind of work around to the issue I am having?
If you have duplicates at the dimension level you can use the FIXED calculation to select just a single row at the dimension level. For example:
{FIXED [Product]: MAX(quoted)}
What this is doing is saying "for each Product, what is the max quoted value?" So if you have duplicates, it'll return only one value
Now we are solving the duplicates problem we can wrap it in SUM:
SUM({FIXED [Product]: MAX(quoted)})
To answer your question about why the sum isn't working, it's because you're trying to do a sum of a sum. If you still wanted to take the approach that was offered to you then you could change it to:
IF [Prod Not Quoted] = 1
then {FIXED [Product]: MAX(quoted)}
end
(I called the aggregation field quoted, but it'll be the measure you're working with)

How to get the COUNT of rows in Crystal Report

I have a data in database which gives me 8 rows based on date range out of which 5 are HCT, is there any formula in crystal report where I can get that count of those 'Abbr' ?
I am comparing HCT text from Dynamic report selection, I need to know can we create a variable which gives us count of 'Abbr'.
like for
HCT should return 5
US should return 2
RN should return 1 value.
UPDATE 1:
Here is what I am trying to do. I have secondary selection criteria as Dynamic report along with date range.
in the above example I have selected only "HCT", now even though sql data is returning 8 rows (HCT,US,RN) I need only the HCT count i.e. 5.
If I select "HCT" and "US" in the secondary criteria then I should get count of both HCT and US i.e. 5 + 2 = 7.
if I am not selecting anything then it should return 0, so irrespective of the data from DB, the value should be summed based on selection of my criteria.
am I clear enough?
Use Running Totals.
Specifically, make a Distinct Count running total for each Date Range code. You can set a formula in the Running Total Wizard to only evaluate records where, for example, {DateRange} = "HCT"
I found the solution for my question, I am just putting it here so that someone may help for the above mentioned formula.
This is what I did
Created a Formula(not running totals) by name SumOfSkills
if({Command.GlobalSkillAbbr} in {?GlobalSkill}) then 1 else 0
here Command.GlobalSkillAbbr is my "HCT" and '{?GlobalSkill} will contain all Global skills.
and used another formuala to sum it up.
Sum(SumOfSkills)
which gives me desired output.

Return 0 value if Details duplicated

I need your help in creating crystal report.
I have a formula in details section that computes working time.
How do I make the value return 0 if it is duplicated?
Here's the scenario
Name Time (Hours:Minutes)
John 1:20
........ 3:30
........ 3:30
Total Hours -> ?
My problem is I dont want to use the duplicated values (3:30) like shown above. I want a total hours for 4:50.
you have two options:
check the option in Database tab.. Select Distinct Records so that duplicate records will be eliminated.
If you don't want to use the first option then to calculate use Running Total so that you sum only those that are distinct...
Create running total something like Do sum only after change of time value
You can use the function "previous" to compare the current value with the previous value, but it works only with fields.
But i am not sure if i understood, you may be more precise about your question.
1) make a formula called "hours" or some other name
if not isnull(previous({Result.Time}) and {Result.Time} = previous({Result.Time}
then 0
else {Result.Time} /* you have to assure the same return type */
2) let the "total hours" be a sum of the formula "hours"
Note that it will work only if the rows are ordered by hours.
The result is the same of using a running total fields as purposed by Siva.