Crosstabs Crystal Reports Null value vs zero - crystal-reports

I'm creating a crosstab report showing the survey history for gopher tortoises (if you must know what that is) monitoring stations. Not all stations are monitored for a given survey and sometimes when we monitor we don't find any and thus record a 0 which is a valid result.
In the crosstab when the station isn't used I would like it to say "N/A" or some other equivalent, but when it's a zero I want it to stay as zero.
I've found so much on how to change a null to a zero, but nothing when you want to keep the zero and somehow note the null.
Below is what the crosstab should look like. You'll see that the 0 in Station4 on 1/1/2004 is "real" (meaning we didn't find any) but all of the N/A's are when we didn't use the station.
Survey Dates
| | 1/1/2000 | 1/1/2002 | 1/1/2004 | 1/1/2006 |
|----------|----------|----------|----------|----------|
| Station1 | 9 | 5 | N/A | N/A |
| Station2 | 5 | 7 | 2 | 6 |
| Station3 | N/A | N/A | 6 | 9 |
| Station4 | 10 | 9 | 0 | 11 |
This is what the Oracle table look like for the 1/1/2000 survey as an example
| SurveyID | StationID | Number |
|----------|-----------|--------|
| 1 | 1 | 9 |
| 1 | 2 | 5 |
| 1 | 4 | 6 |
So, basically how to I keep the zero's and put some text in the nulls in a CR crosstab?
Thanks!

Because CR doesn't differentiate between nulls and actual zeros in the crosstab, you can try replacing actual zero values with a placeholder so you can tell the difference. Note that this solution will only work if you are trying to display the values and not do any aggregate calculations.
First, create a formula that will replace the zeros with a placeholder value. In this case, I'm using -1 since that number should never appear in the database.
//{#Survey Num}
local numbervar totalSurvey;
totalSurvey:={Table.ActiveBurrows} + {Table.InactiveBurrows};
if totalSurvey=0 then -1 else totalSurvey
Use this formula to create your crosstab. Now you need to set a display string so that everything appears correctly. Right-click one of your crosstab cells → hit "Format Field" → select the "Common" tab → then create a "Display String" formula. That formula should be something like:
if currentfieldvalue=-1 then "0" else if currentfieldvalue=0 then "N/A" else totext(currentfieldvalue,0,'')
Now you're basically just printing the real values over top of the placeholders.

Related

Create calculated fields in crosstab

I have a crosstab between supplier and order acceptance status, containing maxvalue of a number.
I need to create a formula like :
IF ACCEPTED > MISSING THEN "GOOD" ELSE "BAD"
Can you help with the syntax?
This is what I get using formula suggested and this is what I should get
ORDER | ACCEP | MISSING | SHOULDBE | NOW |
-------------------------------------------------------------------------------
61010 | 6 | 0 | GOOD | GOOD | FORMULAOK
61011 | 3 | 12 | BAD | BAD | FORMULAOK
63239 | 9 | 11 | BAD | BAD | FORMULAOK
66749 | 0 | | BAD | GOOD | FORMULAnotOK
76824 | 2 | 1 | GOOD | BAD | FORMULAnotOK
Use a SUM() and INT() function to do Conditional Checks ,convert Boolean as Numbers and add the numbers to get total counts. Then its just a comparison.
IF SUM(INT([ACCEPTANCESTATUS]="ACCEPTED")) > SUM(INT([ACCEPTANCESTATUS]="MISSING"))
THEN "GOOD" ELSE "BAD" END
You're data is already pivoted, you can just write a calculated field exactly has you framed your pseudo code:
IF SUM([ACCEP]) > SUM([MISSING]=)
THEN "GOOD"
ELSE "BAD"
END
You can remove the sum elements if you want the value calculated for every row (and not aggregated).

Combine multiple rows of the same column into one row

I have following data from my database:
+------+-----------+-------------+---------------+
| ID | SomeValue | SomeDate | SomeOtherDate |
+------+-----------+-------------+---------------+
| 123 | 12345 | 01.01.2017 | 01.01.2018 |
| 123 | 54321 | 01.01.2017 | 01.01.2019 |
| 123 | 25314 | 01.01.2017 | 01.01.2020 |
+------+-----------+-------------+---------------+
I want the following format in Crystal Reports:
+------+---------------+---------------+---------------+
| ID | SomeValue2018 | SomeValue2019 | SomeValue2020 |
+------+---------------+---------------+---------------+
| 123 | 12345 | 54321 | 25314 |
+------+---------------+---------------+---------------+
How can I do this, if it's even possible? I've tried multiple examples but cant seem to make it work. I was successfully able to make the headings.
It is difficult to make Crystal Reports evaluate things horizontally. The entire system is designed to evaluate vertically. (Things on the top of a report are evaluated before things below them.)
However you might be able to get a CrossTab to do this. First you'd want to make a new Forumla field for your columns. It would be structured something like:
"SomeValue" + Year({#SomeOtherDate})
When you design the crosstab, you'll want to set ID as the Row, your new formula from above as the Column, and the Summarized Field will be SomeValue. You'll also want to suppress the Grand Totals in the Customize Style.

Tableau - Show multiple discrete string (dropdown) dimensions side-by-side in a single table

I have a list of survey results that looks similar to the following:
| Email | Question 1 | Question 2 |
| ----------------- | ---------- | ---------- |
| test#example.com | Always | Sometimes |
| test2#example.com | Always | Always |
| test3#example.com | Sometimes | Never |
Question 1 and Question 2 (and a few others) have the same discrete set of values (from a dropdown list on the survey).
I want to show the data in the following format in Tableau (a table is fine, but a heatmap or highlight table would be best):
| | Always | Sometimes | Never |
| ---------- | ------ | --------- | ----- |
| Question 1 | 2 | 1 | 0 |
| Question 2 | 1 | 1 | 1 |
How can I achieve this? I've tried various combinations of rows and columns and I just can't seem to get close to this layout. Do I need to use a calculated value?
As far as I know - it is not natively possible with Tableau, because what you have is kind of a pivot table.
What you can do is unpivot the whole table as explained here https://stackoverflow.com/a/20543651/5130012, then you can load the data into Tableau and create the table you want.
I did some dummy data and tried it.
That's my "unpivoted" table:
Row,Column,Value
test,q1,always
test,q2,sometimes
test1,q1,sometimes
test1,q2,never
test10,q1,always
test10,q2,always
test11,q1,sometimes
test11,q2,never
And that's how it looks in Tableau:

Emacs: Org-mode spreadsheet: targeting via hline

I'm trying to log my hours in org mode:
** Bob Johnson, Bob's SEO
| subject | time | minutes | total hours |
|-----------------------------------------------+---------------------------+---------+-------------|
| optimization report | 2011/07/11 8-10:00 PM PST | 120 | 2 |
| phonecall to dicuss report and plan of action | 2011/07/13 5:41 PM | 43 | 0.71666667 |
|-----------------------------------------------+---------------------------+---------+-------------|
| | | 249 | 4.15 |
#+TBLFM: $4=#0$-1/60::#6$3=vsum(#I..#II)
The main problem is the expression above that sums up total hours:
#6$3=vsum(#I..#II)
Should be something like:
#||+1$3=vsum(#I..#II)
So that as the spread sheet grows the last item in the second to last column will always sum the total. It doesn't work when I set it this way (and +II, and other ways) however.
Any ideas?
Thanks!
The closest you could come to relative references would be to change your formula to:
#+TBLFM: $4=$-1/60::#>$3=vsum(#I..#II)
The #0 is implied by -1.
For the second formula the #> means the last row, so as long as you don't add additional rows below your total row the results will be in the right place. If you add additional below it you will simply have to adjust the number of > signs.
EDIT:
You can also name the cell in question so that it doesn't get changed regardless:
Org-Manual
|-----------------------------------------------+---------------------------+---------+-------------|
| | | 163 | 2.7166667 |
| ^ | | total | total |
#+TBLFM: $4=$-1/60::$total=vsum(#I..#II)
You need the total name for both total rows, otherwise your minutes won't add up.
Use the M-S-up,down,left,right family of commands to manipulate (insert/delete row/column) the table, and the formula will be adjusted automatically.

Copying a range remotely

I've got a table named FOO with the column ("Porc" |- 3 7 15 50 15 7 3) and I'm copying the numbers to another table, shown below. I'm doing it the hard way, cell for cell, but I was wondering if there is a way to copy that range of the remote table (A2 to the bottom) in a single command.
| Pr (%) | ROE de A | ROE de B |
|--------+----------+----------|
| 3 | -11.43 | -34.29 |
| 7 | 0. | -11.43 |
| 15 | 3.43 | 0. |
| 50 | 12. | 17.14 |
| 15 | 20.57 | 34.29 |
| 7 | 24. | 41.14 |
| 3 | 30.86 | 54.86 |
|--------+----------+----------|
| Média | 11.86 | 16.41 |
| Desvio | 8.37 | 17.61 |
#+TBLFM: #2$1=remote(FOO, A2)::#3$1=remote(FOO, A3)::#4$1=remote(FOO, A4)::etc
Thanks
It seems your answer is in the org-mode manual:
$3 = remote(FOO, ###$2)
copy column 2 from table FOO into
column 3 of the current table For the
second example, table FOO must have at
least as many rows as the current
table. Inefficient for large number of
rows.
A Kind of Corollary: Copying all fields in a given row
So just as:
$3 = remote(FOO, ###$2)
copies all the fields from a given column (col2) into column three of the new table, then:
#3 = remote(FOO, #1$$#)
copies all the fields from a given row (row1) into row 3.
There's something about how this standard reference form #r$c interacts with the ## and $# notation that makes this seem a bit abstruse. e.g. this is all the org manual has to say about this remote reference syntax:
## and $# can be used to get the row or column number of the field where the formula result goes.
Umm…?
Posting this example here because I found it all a bit mystifying and hope this helps some else save a few minutes when dealing with rows and tables in the awesome org-mode