I have crystal generating the following output in my Details section
Cats Group
Number How Old
________________________
12 0-30 days old
32 0-30 days old
34 31-60 days old
Dogs Group
Number How Old
________________________
22 over 61 days old
123 0-30 days old
but i need the above info in a table format
Group 0-30 days old 31-60 days old over 61 days old
______________________________________________________
Cats 2 1 0
Dogs 1 0 1
thanks
You need a Cross-Tab;
Open Cross-tab expert
Drag group into columns
Drag animal type into rows
Drag animalinto value and set count as summarize option
Related
I have data with 2 columns, in the following format:
ID
Date
1
1/1/2020
1
27/7/2020
1
15/3/2021
2
18/1/2020
3
1/1/2020
3
3/8/2020
3
18/9/2021
2
23/8/2020
2
30/2/2021
Now I would like to create a calculation field in Tableau to find per ID the difference between the different dates. For any value e.g. days.
For example for ID 1 the difference of the two dates according to calendar is 208 days. Next the difference of the second to third date for the same ID is 231 days.
A table calc like the following should do if you get the partitioning, addressing and ordering right — such as setting “compute using” to Date.
If first() < 0 then min([Date]) - lookup(min([Date]), -1) end
I have a streaming data coming in from kafka into dataFrame.
I want to remove duplicates based in Id and keep the latest records based on timestamp.
Sample data is like this :
Id Name count timestamp
1 Vikas 20 2018-09-19T10:10:10
2 Vijay 50 2018-09-19T10:10:20
3 Vilas 30 2018-09-19T10:10:30
4 Vishal 10 2018-09-19T10:10:40
1 Vikas 50 2018-09-19T10:10:50
4 Vishal 40 2018-09-19T10:11:00
1 Vikas 10 2018-09-19T10:11:10
3 Vilas 20 2018-09-19T10:11:20
The output that I am expecting would be :
Id Name count timestamp
1 Vikas 10 2018-09-19T10:11:10
2 Vijay 50 2018-09-19T10:10:20
3 Vilas 20 2018-09-19T10:11:20
4 Vishal 40 2018-09-19T10:11:00
Older duplicates are removed and only the recent records are kept based on the timestamp field.
I am using watermarking for timestamp field.
I have tried using "df.removeDuplicate" but it keeps older records intact and anything new gets discarded.
Current code is as follows :
df = df.withWatermark("timestamp", "1 Day").dropDuplicates("Id", "timestamp")
How can we implement custom dedup method so that we can keep latest record as unique record?
Any help is appreciated.
Sort the timestamp column first before dropping the duplicates.
df.withWatermark("timestamp", "1 Day")
.sort($"timestamp".desc)
.dropDuplicates("Id", "timestamp")
crystal report grouped by company and invoiced
company name invoiceNo which has max(dayslate)? (maxdaysLate)
------------- records -------------------------------
there is a chance of one invoice is assigned to multiple companies,
for example
company1 inv1 30 days late (max(dayslate) col below)
invoiceNo duedate dayslate (cal field today - duedate)
inv1 2016-01-01 30
inv2 2016-01-01 30
Company2 inv3 26 days late(inv1 below has max but already in comp1, so 2nd max)
invoiceNo duedate dayslate
inv1 2016-01-01 30
inv3 2016-01-04 26
need help how to write a formula for max days late record field in a group (ex: inv1)
how to calculate max days as already one is used find second so on...
edit
days late is column which is calculated column (today - due date)
on group want to display which has max days late of that group and its related invoice number
there is chance of one invoice has been assigned to multiple companies, in case any that invoice has max days in 2 groups it should be calculated to only one company group and on other group it should consider the second highest
I have some data in table SSTemp like this ("..." indicates data omitted for readability):
Month Year Number Gross Net
1 2013 1 1,000 500
2 2013 1 1,000 500
...
12 2013 1 1,000 500
1 2014 1 1,000 500
2 2014 1 1,000 500
...
12 2014 1 1,000 500
1 2015 1 1,000 500
...
12 2015 1 1,000 500
I am new to Crystal Reports and am using version 8 (no, we can't upgrade). I want to roll up the totals for all line items in years past and leave the data as-is for the current year in the same report. Database field {CONTROLFILE.CURRENTYEAR} contains the current bookkeeping year for our system which is vital to determine the rollup groups. The CONTROLFILE table contains general settings for the system and has no data in it useful for JOINing, however I need to consider CURRENTYEAR for the grouping. The MONTH column should be blank on the summary lines, and indicate month on the current year lines. The end result data should look like this:
Month Year Number Gross Net
2013 12 12,000 6,000
2014 12 12,000 6,000
1 2015 1 1,000 500
2 2015 1 1,000 500
...
12 2015 1 1,000 500
Any suggestions would be most appreciated!
Use sub report concept.
In main report calculate for previous years in sub report calculate for current year.
In main report group by year And suppress details show summary in group footer in another group footer section place sub report and just place data in detail part don't group
I'm building a report in Crystal Reports 2008. The report is dealing with employee's schedules. There are time slots where the schedule is open, and time slots where the schedule is unavailable.
Currently, I've built my logic so that it finds the start and end of an unavailable time. The report them tells me how many hours that particular staff person was unavailable.
My issue is that sometimes, staff people have a block at the beginning of their schedule marked as 'unavailable', and a block at the end of the day as 'unavailable', but between the two they are 'open'. Thus, the report says that particular staff person was out the whole day, but they actually worked. It isn't an option to tell these particular staff people how to schedule their day - they decide their own schedule, and I write the report to accomodate their needs.
SCHEDULE_TIME EMP_ID UNAVAILABLE_CODE WORK_LENGTH
7/5/2011 11:00 100 NULL 15
7/5/2011 11:15 100 NULL 15
7/5/2011 11:30 100 NULL 15
7/5/2011 11:45 100 NULL 15
7/5/2011 12:00 100 15 5
7/5/2011 17:00 100 15 5
This example shows how somebody would have a 5 hour block calculated for unavailable time, but it's only 2 appointments. For the code, I'm using DATEDIFF between appointment times.
(Essentially, they have built in more than one 'unavailable' block, and my logic will only accomodate one 'unavailable' block per day).
I'm pretty sure that I need to run a type of DO...WHILE loop within the report in order to calculate the total hours unavailable. I'm just not sure how to structure the loop in Crystal Reports.
Maybe i'm missing something but what you want to do looks straight forward. Two obvious options:
Running total:
Set the field to {TABLE.WORK_LENGTH}
Set the type to sum
Set the evaluation formula to not(isnull({TABLE.UNAVAILABLE_CODE}))
Set the reset on change of group/field {TABLE.EMP_ID} (assuming you're looking for totals per employee)
Formula/sum:
Create a formula field unavailable_time with if not(isnull({TABLE.UNAVAILABLE_CODE})) then {TABLE.WORK_LENGTH} else 0
Create a group on {TABLE.EMP_ID}
Create a sum on your formula field in the group footer