Crystal Report Crosstab Calculations - crystal-reports

In my crosstab, I am trying to add a summarized field that will take two other summarized fields and create a percentage based off of those.
One field totals all of the appointments for a provider (count of appt), while the other one totals the number of possible sales opportunities (sum of opp). What I am trying to add is a summarized field that is esentially opp/appt in percentage form.
How would I go about doing this?
Week 1 | Week 2 | Week 3 | Week 4|
Provider A | | | |
Appts 3 | 3 | 4 | 1 |
Opps 1 | 2 | 1 | 1 |
Opps/Appts ?? | ?? | ?? | ?? |

In Crystal Reports 2008:
Select 'Opps' calculation field; choose Embedded Summary, then Insert Embedded Summary
Select newly-created embedded-summary field; right click; choose Embedded Summary, then Edit Calculation Formula
Add the following text:
Local Numbervar Denominator:=GridValueAt (CurrentRowIndex, CurrentColumnIndex, 0);
Local Numbervar Numerator:=GridValueAt (CurrentRowIndex, CurrentColumnIndex, 1);
If Denominator<>0 Then Numerator/Denominator * 100;

Related

Calculate Average of Price per Items per Month in a Few Years Postgresql

I have this table inside my postgresql database,
item_code | date | price
==============================
aaaaaa.1 |2019/12/08 | 3.04
bbbbbb.b |2019/12/08 | 19.48
261893.c |2019/12/08 | 7.15
aaaaaa.1 |2019/12/17 | 4.15
bbbbbb.2 |2019/12/17 | 20
xxxxxx.5 |2019/03/12 | 3
xxxxxx.5 |2019/03/18 | 4.5
how can i calculate the average per item, per month over the year. so i get the result something like:
item_code | month | price
==============================
aaaaaa.1 | 2019/12 | 3.59
bbbbbb.2 | 2019/12 | 19.74
261893.c | 2019/12 | 7.15
xxxxxx.5 | 2019/03 | 3.75
I have tried to look and apply many alternatives but i am still not get the point, would really appreciate your help because i am new to postgresql.
I don't see how the question relates to a moving average. It seems you just want group by:
select item_code, date_trunc('month', date) as date_month, avg(price) as price
from mytable
group by item_code, date_month
This gives date_month as a date, truncated to the first day of the month - which I find more useful that the format you suggested. But it you do want that:
to_char(date, 'YYYY/MM') as date_month

Print GroupWise Sum details in another Group Jasper Report

I am using jasper studio and I want to print Group wise sum in another group footer for better understanding take a look below.
Class Group Header: Class One
Student Group Header: Student One
Subject | Total Marks | Obtained Marks
ABC | 100 | 50
PQR | 100 | 80
AER | 100 | 30
Student Group Footer: Student One Total Obtained Marks : 160
Student Group Header: Student Two
Subject | Total Marks | Obtained Marks
ABC | 100 | 20
PQR | 100 | 10
AER | 100 | 30
Student Group Footer: Student Two Total Obtained Marks : 60
Here above i can print each student's obtained marks separately in student group footer, but i want to print same in Class group footer which means i want output like below
Class Group Header: Class One
Student Group Header: Student One
Subject | Total Marks | Obtained Marks
ABC | 100 | 50
PQR | 100 | 80
AER | 100 | 30
Student Group Header: Student Two
Subject | Total Marks | Obtained Marks
ABC | 100 | 20
PQR | 100 | 10
AER | 100 | 30
Class Group Footer:
Student One Total Obtained Marks : 160
Student Two Total Obtained Marks : 60
How can i achieve this result? Thank you in advance :)
In Class group footer (or summary band) , drag and drop 'Crosstab' from pallete.
Select Create a crosstab from existing database
select column group = class
select row group = Student
select Measures = Marks / calculation=sum
You can watch tutorials on how to use Crosstab in jasper studio

Count records between rolling date range in Tableau

I have a file with a [start] and [end] date in Tableau and would like to create a calculated field that counts number of rows on a rolling basis that occur between [start] and [end] for each [person]. This data is like so:
| Start | End | Person
|1/1/2019 |1/7/2019 | A
|1/3/2019 |1/9/2019 | A
|1/8/2019 |1/15/2019| A
|1/1/2019 |1/7/2019 | B
I'd like to create a calculated field [count] with results like so:
| Start | End | Person | Count
|1/1/2019 |1/7/2019 | A | 1
|1/3/2019 |1/9/2019 | A | 2
|1/8/2019 |1/15/2019| A | 2
|1/1/2019 |1/7/2019 | B | 1
EDITED: A good analogy for what [count] represents is: "how many videos does each person rented at the same time as of that moment?" With the 1st row for person A, count is 1, with 1 item rented. As of row 2, person A has 2 items rented. But for the 3rd row [count]= 2 since the video rented in the first row is no longer rented.

Crystal 2008: Suppress record with multiple criteria

Crystal report looks like this:
No.| Name | Test - | Date
1 --| Fido - | yes -- | 1/2/2010
2 --| Rover | no --- | 1/2/2010
3 --| Fido - | yes -- | 1/2/2010
4 --| Fido - | yes -- | 1/8/2010
5 --| Rover | no --- | 1/8/2010
There are lots of observations with much duplication. Currently report suppresses records if duplicate in first column. Only records 1 and 2 would show up.
I need to be able to suppress records where both columns 1 and 3 are the same regardless of what is in column 2. In this case records 1,2,4,5 would all show up.
You can do this. try below way.
Create an array with the values first, For that purpose concatenate the required fields and create an array and select only those that are unique.
create a formula #finalvalues
Global Stringvar array mylist;
if Name&ToText(Date) in mylist
Then
1
else
mylist:=mylist+Name&ToText(Date);
0;
Now go to the supress part of the section where fields are placed and write below code.
if {#finalvalues}=1
then true
else false

DB2, get all rows with 1/100 of a column

I have these rows in my product table:
product_name | product_code | percentage.
prod1#00X | 1 | 50
prod2#00X | 2 | 20
prod3#00X | 3 | 30
I wanna select all the elements of my table but I wanna show 1/100 of the percentage
The result should be:
prod1#00X | 1 | 0.50
prod2#00X | 2 | 0.20
prod3#00X | 3 | 0.30
How can I do?
I wanna find another solution not this:
SELECT product_name, product_code, (percentage/100) as percentage FROM product
Note: I have several columns in my table, not only product_name | product_code | percentage.
Try this way:
SELECT (percentage/100) as percentage,*
FROM product
OR
Using another alias:
SELECT *,(percentage/100) as NewPercentage
FROM product
you can use select statement as
SELECT *
, (percentage/100) as newpercentage
FROM product
where (your condition )