how to merge cells in fastreport 4? - delphi

sample data
01 A AA
01 A BB
02 B CC
03 A DD
03 A EE
the primary key is first column.
the first column and second column are common value.
the last column is personal value.
i want to merge rows in the first column and second column when the value of the first column is change.
my way is
first, write in fastreport's code using 'if' command.
second, use 'groupheader' and add the common columns in the section.
however, the first way have a problem that i don't know how to control index.
the second way is the groupheader's columns overflow PageFooter when a group end at the end of a page and the other group start at the first of next page.
please..... answer me...TTTTTT!
the first box is Groupheader's columns and the second box is overflowed data.

Try to use TfrxDBCrossView object

Related

How to drag copy a data validation and increment the column letter

I'm trying to make a drop-down list in my spreadsheet, my spreadsheet has a couple of sheets but the main two sheets are "Master" and "Sheet3".
I have made the drop-down list using the Data -> Data validation as shown in the below screenshot:
And in the "Sheet3" sheet there is a big table (1000 columns) of data that I want to make a drop-down list from, from each column in it.
Now what I want is to drag copy this cell down so that the criteria will be like this:
=Sheet3!A1:A
=Sheet3!B1:B
=Sheet3!C1:C
=Sheet3!D1:D
...etc
and so forth for 1000 rows, but when I do this, it does not increment the column letter, it's just like the first cell criteria value (=Sheet3!A1:A) for all other rows.
Is there a way to make this work without me having to edit each row in this 1000-row column manually?
Thank you all.
We have Sheet3 with 1000 column and we want to get a drop down of all 1000 column in Master sheet in a single column.
Solution
01 - Transpose Sheet3 to use it as a source of Data validation.
=TRANSPOSE(Sheet3!A1:999)
02 - Go to Data validation and set the range to ='Sheet3 Transposed'!1:1 as soon as you click save it automatically changes to ='Sheet3 Transposed'!$1:$1 with a abslout refrence just change it back to ='Sheet3 Transposed'!1:1 with removing $ dollar signs.
03 - Copy the the drop down cell D2 and paste it in the range D2:D1001, we get Error: Invalid Input must fall within specified range, in the whole range D2:D1001, to solve it copy the range 'Sheet3 Transposed'!A1:A1000 and in D2 right click: paste special > Values only
enjoy :D

Add column of Row numbers where row is not blank or does not start with [

I'm trying to achieve the following row numbering:
Count
01
A
[A
02
A
03
A
So basically any line thats blank or starts with a [ is ignored in the count
I've tried modifying this formula so that it also ignores cells that start with a [
={"Sr. No.";ArrayFormula(ifna(vlookup(row(B2:B),{filter(row(B2:B),B2:B<>""),sequence(counta(B2:B),1)},2,0)))}
The above works fine but when I added in regexmatch(B2:B, "^[^\[]) ie.
={"Sr. No.";ArrayFormula(ifna(vlookup(row(B2:B),{filter(row(B2:B),B2:B<>"",regexmatch(B2:B, "^[^\[])),sequence(counta(B2:B),1)},2,0)))}
It fails :-(
Any help/alternate approaches would be much appreciated
Explanation:
The filter and sequence formulas with the added condition [ now have different number of columns (in my example, 4 vs 5), thus returning an error.
Solution:
This can be fixed by adding -countif(LEFT(B2:B),"[") to the sequence formula:
={"Sr. No.";ArrayFormula(ifna(vlookup(row(B2:B),{filter(row(B2:B),B2:B<>"",LEFT(B2:B)<>"["),sequence(counta(B2:B)-countif(LEFT(B2:B),"["),1)},2,0)))}
Please note that I used LEFT instead of regex, it does the same text condition.
Sample:

Filter by Date range and sum Row values by Column (in Google Sheets)

Do you have a suggestion on how to make a formula for the problem written in the title?
Here is the example so that you can get an idea of the data format:
Name,Location,Category,Total views for your listing,Total uniqe page views for your listing,Average time on page (listing),total,Facebook,Reviews,Telephone,Treatment Menu,Get Directions,Book Appointment,Enquiry,Instagram,Date
John,NSW Sydney,Apple,1,1,0:00:12,0,0,0,0,0,0,0,0,0,13/Nov/2018
Mike,NSW Sydney,Orange,1,1,0:00:10,0,0,0,0,0,0,0,0,0,13/Nov/2018
Kenny,NSW Sydney,Pear,1,1,0:00:00,4,1,1,1,1,0,0,0,0,13/Nov/2018
John,NSW Sydney,Apple,20,1,0:00:12,0,0,0,0,0,0,0,0,0,14/Nov/2018
Chris,NSW Sydney,Orange,1,1,0:02:48,3,0,0,1,1,1,0,0,0,14/Nov/2018
Stef,NSW Sydney,Orange,10,1,0:07:22,6,1,1,0,1,0,1,1,1,14/Nov/2018
So, the issue is in making a formula that gets put into cells containing numerical values (from D to O), for each of the Name rows.
What it should look like is:
for John and for 13th and 14th of November, the cell in column B in that row should be 21
for Mike for 13th and 14th, it returns 1
for Jenny, which is not on the list, because she didn't have any values in any of the numerical columns for that day (or a group of days), it should return 0
All of these should appear in the "Main Dashboard" sheet, while the data is stored in the "directory statistics" sheet.
The predefined list of all the possible Names, Categories and Locations is in the "customList" sheet. This means that we don't need to search through the whole dataset of all the values for all the dates, but rather only search through the Names in the "customList". "Name" should be the key value that connects values in different dates.
So far, I have tried with this formula:
=Filter('directory statistics'!A2:A,'directory statistics'!$P2:$P=$P2)
It looks for the name column (A) and then returns the value if the date entered (in P2) matches the value in that sheet for the date column (P)
And then I got stuck! :)
Thank you!
I'm not sure why FILTER. Assuming Name in A1, and Row 1 and ColumnA in Main Dashboard set up as in my image, then:
=SUMIFS('directory statistics'!D$1:D$7,'directory statistics'!A$1:A$7,$A2,'directory statistics'!P$1:P$7,">="&B$1,'directory statistics'!P$1:P$7,"<="&C$1)
in B2 and copied down would appear to me to achieve the results you seek.

How to use "if contains"?

I'm trying to make a scheduler for work and I have a dropdown list of the hours that the employees work in one column and I want it to display how many hours it is next to that. I.e.:
Column B (Selected from a drop down menu) Column C
6:00 - 14:30 to display 8 as it is an 8 hour shift
10:00 - 15:00 to display 5 as it is an 5 hour shift
Is there a way to do this?
So for the sake of clarity, I am going to develop this step by step, in several columns. These could be combined into one impenetrable formula, but that will not help you follow. You can do what I suggest here and then hide the columns with the calculation.
Suppose your time is in column A. You can do the following in the first row (mine assumes row 1, if you have headers, probably row 2) and then copy the formulas on down. In column B, I placed, =search("-",A1), which tells where the - sign is. In column C, I find the first time as a string with =left(A1,B1-2), which takes the first characters up to 2 before the dash. In column D I have =mid(A1,B1+2,5) which takes from 2 characters after the dash to the end (if it is only 4 characters long, it copies 4 not 5),and finally in column E we find the desired result, with =HOUR(timevalue(D1)-timevalue(C1)).
That does what you asked. If you wanted to add minutes you could use =MINUTE(timevalue(D1)-timevalue(C1)). Finally if a 22:00 - 6:00 graveyard shift existed, you would need to add logic for it.
You could also simplify the string calculation by in column B using the formula =split(A1,"-") and then putting =HOUR(timevalue(C1)-timevalue(B1))
And so if you really want a single formula, it could be =hour(INDEX((split(A1,"-")),2)-INDEX((split(A1,"-")),1)), which subtracts the first part from the second and converts to hours.
If in the course of time you want to handle the wrap around midnight, =iferror(hour(INDEX((split(A1,"-")),2)-INDEX((split(A1,"-")),1)),24-hour(INDEX((split(A1,"-")),1)-INDEX((split(A1,"-")),2))) should do the trick.
UPDATE: Sheets recognizes the times that resulted from the split as times. So if in B1 you place =split(A1,"-"), D1 can contain =C1-B1 if you are willing to keep the minutes. It even gives the right answer for 22:00 - 2:00.
Make a table with a column for the shifts (this could be the list used for the Validation, if you chose that method) and a column immediately to its right of the respective shift durations. I named that table Larry. Then in C2 (assuming your first dropdown is in B2):
=ArrayFormula(vlookup(B1:B,Larry,2,0))

Manipulate COBOL data structure

I would like informations to manipulate tables.
I encounter few problem with a piece of cobol code like below:
01 TABLE-1.
05 STRUCT-1 OCCURS 25 TIMES.
10 VALUE-1 PIC AAA.
10 VALUE-2 PIC 9(5)V999.
05 NUMBER-OF-OCCURS PIC 99.
How do you update values? (update a VALUE-2 when you know a VALUE-1)
How look up a value and add new one?
Thanks a lot!
How to look up a value/How to update a value
First you have to look up the record (row) that you want to update. This is typically done by searching the table for
a given key value. COBOL provides a couple of ways to do this. I recommend that you start by
reviewing the COBOL SEARCH
statement. If STRUCT-1 records are sorted, you could use SEARCH ALL, otherwise you must use SEARCH or just code
your own search loop. In order to use any of these techniques you will need to declare another variable somewhere
in your program to use as an index (offset) into the STRUCT-1 table. COBOL provides the INDEXED BY phrase on the
OCCURS clause to declare an index specific to the given table
(see OCCURS)
Once you have set the index into STRUCT-1 to point to the row to be updated you just MOVE the
value to the appropriate variables within that row, for example
MOVE 123.456 TO VALUE-2 (IDX-1)
where IDX-1 is the index referred to above. Note that you can use either an integer or
index variable
to specify the row number to be updated, you are not limited to using an INDEX type variable. However,
it is generally more efficient to use INDEX variables over other types of variables, particularily
when working with multi-dimensional tables where the program makes lots of references to the table.
How to add a new row
First recognize that STRUCT-1 contains exactly 25 rows. COBOL does not have a mechanism to dynamically
increase or decrease this number (I've heard this will possible in the next ISO COBOL standard - but don't
hold your breath waiting for it). Technically all 25
rows are available at any time. However a common convention is to 'grow' a table from being empty
to full sequentially, one row at a time. To use this convention you need to assign a variable to
keep track of the last used row number (don't forget to initialize this variable to zero at program startup).
In your example it looks like the variable NUMBER-OF-OCCURS does this job
(I didn't mention it but, you need this variable to bound the SEARCH discussed above).
To 'add' a row, just increment NUMBER-OF-OCCURS by 1. Be careful not to exceed the table size. Example
code might be:
IF NUMBER-OF-OCCURS < (LENGTH OF TABLE-1 / LENGTH OF STRUCT-1 (1))
ADD +1 TO NUMBER-OF-OCCURS
ELSE
table is full, preform some error/recovery routine
END-IF
The above code avoids the explicit use of the number of occurs in TABLE-1 which in turn can save
a number of maintenance problems when/if the number of OCCURS is ever changed.
See the NOTE at the bottom: There is a really big Woops here - did you catch it!
Now back to the search problem. The following code example illustrates how you might
proceed:
WORKING-STORAGE Declaration:
01 FOUND-IND PIC X(1).
88 FOUND-YES VALUE 'Y'.
88 FOUND-NO VALUE 'N'.
77 MAX-IDX USAGE IS INDEX.
01 TABLE-1.
05 STRUCT-1 OCCURS 25 TIMES INDEXED BY IDX-1.
10 VALUE-1 PIC AAA.
10 VALUE-2 PIC 9(5)V999.
05 NUMBER-OF-OCCURS PIC 99.
What was added:
FOUND-IND is used to indicate whether the row you are looking for has been found. The 88 levels give specific values to set/test
MAX-IDX is used to set an upper bound limit on the search. You could use NUMBER-OF-OCCURS in the upper bounds test but this would force a data type converson on every test which isn't very efficient
IDX-1 is used as the index (offset) into the STRUCT-1 table.
Personally, I would declare NUMBER-OF-OCCURS as PIC S9(4) BINARY but what you have will work.
Assuming that STRUCT-1 is not sorted and NUMBER-OF-OCCURS represents the current
number of active rows in STRUCT-1 this
is an example of how you might code the SEARCH when looking for the value 'ABC':
SET FOUND-NO TO TRUE
IF NUMBER-OF-OCCURS > ZERO
SET IDX-1 TO 1
SET MAX-IDX TO NUMBER-OF-OCCURS
SEARCH STRUCT-1
WHEN IDX-1 > MAX-IDX
CONTINUE
WHEN VALUE-1 (IDX-1) = 'ABC'
SET FOUND-YES TO TRUE
END-SEARCH
END-IF
IF FOUND-YES
row found, use IDX-1 to reference the row containing 'ABC'
ELSE
row not found, IDX-1 does not contain a valid index
END-IF
How it works:
Start by assuming the row is not in the table by setting FOUND-NO to true.
The first IF ensures that there is at least 1 active row in STRUCT-1 before beginning the search (it is an error to set an INDEX to zero - so you need to guard against that).
The SEARCH terminates when the first SEARCH WHEN clause is satisified. That is why the 'do nothing' verb CONTINUE can be used when we run out of rows to search. The other terminating condition (finding the value you are looking for) is the only place where FOUND-YES can be set.
When the SEARCH completes, test for success or failure then act accordingly.
Some exercises for you to research:
Why did I not have to code an AT END clause in the SEARCH statement?
Why did I not have to code a VARYING clause in the SEARCH statement?
Why did I code the WHERE clauses in the order that I did?
Hope this gets you started down the right path.
Edit
In response to your question in the comments: Could we use NUMBER-OF-OCCURS as index for the search. The
answer is yes, but you need to implement some different rules. When using NUMBER-OF-OCCURS
as an index you can no longer use it to keep track of how many rows currently contain
valid data. This means you need another mechanism to identify unused rows in STRUCT-1.
This might be accomplished by initializing un-used rows with a sentinal value (eg. LOW-VALUE) that you
will never actually want to put into the table. The SEARCH becomes:
SET FOUND-NO TO TRUE
MOVE 1 TO NUMBER-OF-OCCURS
SEARCH STRUCT-1 VARYING NUMBER-OF-OCCURS
WHEN VALUE-1 (NUMBER-OF-OCCURS) = 'ABC'
SET FOUND-YES TO TRUE
END-SEARCH
The above will search every row in STRUCT-1 in the event that the value you are searching for
(ie. ABC) is not in the table. As an optimization you can add a second WHEN clause to terminate the
search upon finding a sentinal value:
WHEN VALUE-1 (NUMBER-OF-OCCURS) = LOW-VALUE
CONTINUE
The above assumes LOW-VALUE was used to identify unused rows. You can also drop IDX-1 and MAX-IDX
from your working storage since this solution doesn't need them.
Using NUMBER-OF-OCCURS as an index also means you must change the way you search for an empty row
to insert a new value. The easiest way to do this is to search the table using the above
code for LOW-VALUE instead of 'ABC'. If FOUND-YES has been set at the end of the search, then
NUMBER-OF-OCCURS is the index of the first unused row. If FOUND-NO has been set, then the table is
already full.
The above code is a lot simpler than what I initially suggested. So why did I give you the more
complicated solution? The more complicated solution is more efficient because it makes many
fewer internal offset calculations and data type conversions when running through the table.
It also avoids doing an additional
SEARCH to find the next unused row. These efficiencies
may not be of concern in your application, but if the tables are large and accessed frequently you
should be aware of the performance aspect of searching tables and forced data type conversions (for
example the cost of converting a PIC 99 field into an index reference).
Note:
My original example to calculate whether the table was full using the LENGTH OF special register
would work in this example but has a really bad built in assumption! The LENGTH OF TABLE-1 includes
not only the STRUCT-1 table but the NUMBER-OF-OCCURS too. The length of NUMBER-OF-OCCURS is less than one
occurance of STRUCT-1 so it all works out ok due to truncation of the result into an integer value.
This is a very good example of code working correctly for the wrong reason! To make the proper calculation
you would have to adjust your working storage to something like:
01 TABLE-1.
05 STRUCT-TABLE.
10 STRUCT-1 OCCURS 25 TIMES.
20 VALUE-1 PIC AAA.
20 VALUE-2 PIC 9(5)V999.
05 NUMBER-OF-OCCURS PIC 99.
and the bounds calculation would become:
IF NUMBER-OF-OCCURS < (LENGTH OF STRUCT-TABLE / LENGTH OF STRUCT-1 (1))
ADD +1 TO NUMBER-OF-OCCURS
ELSE
table is full, preform some error/recovery routine
END-IF
Or you could just move NUMBER-OF-OCCURS out of the TABLE-1 record definition.
In order to populate and amend data in tables in working-storage section you need to use a subscript/index, which you can define in the working-storage, and then write the processing
code in the procedure division. In this instance you could use a perform..until.
Wow...that was a long answer. Assume a numeric named II:
Perform varying II from 1 by 1
until II > NUMBER-OF-OCCURS
If Value-1 (II) = Known-Value-1
Move New-Value-2 to Value-2 (II)
End-If
End-Perform

Resources