WEBI find duplicate rows (with exception of certain columns) and highlight - business-objects

consider the following table:
+------+------+----------+----------------+
| Col1 | Col2 | Col3 | Numeric Column |
+------+------+----------+----------------+
| ValA | ABC | Value 3 | 101 |
| ValF | DEF | Value 10 | 101 |
| ValC | DEF | Value 10 | 101 |
| ValB | GHI | Value 12 | 103 |
+------+------+----------+----------------+
I would like to find duplicate rows by comparing values across multiple columns, and highlight the values in the [Col1] column when duplicate rows are found (OR highlight the whole row, whatever is easier). So in the above table I would like to compare values of the [Col2], [Col3] and [Numeric Column] columns.
And in this example, ValF and ValC in [Col1] would be highlighted. I am not sure how to go about this.

I figured it out, see steps below.
Create a dimension variable and concatenate all the columns you like to compare into a variable.
Variable name: Concat_col
​Variable formula: =[Col2]+[Col3]+[Numeric Column]
Create a measure variable and refer to the first variable.
​Variable name: Count_col
​​Variable formula: =RunningCount(NoFilter([Concat_col]);([Concat_col]))
Create a measure variable and refer to the first and second variable.
Variable name: Max_col
Variable formula: =Max(NoFilter([Count_col])) In ([Concat_col])
Now create a Formatting rule:
And populate as follow:
To apply to a whole row, select the columns one by one and click Formatting Rules > 'Conditional Format' (this is the name of the formatting rule we just created earlier).

Related

Avoid Duplicate Records with BeforeChange Table Event

I have a situation in MS Access database that I must prevent duplicate records based on combination of three attributes:
StudentNumber
ColleagueID
TypeOfAttending
So, for one combination (StudentNumber & ColleagueID) I have three types of attending: A, B and C.
Here is an example:
+---------------+-------------+---------------+
| StudentNumber | ColleagueID | AttendingType |
+---------------+-------------+---------------+
| 100 | 10 | A |
| 100 | 10 | B |
| 100 | 10 | C |
| 100 | 11 | A |
| 100 | 11 | B |
| 100 | 11 | C |
| 100 | 11 | C |
+---------------+-------------+---------------+
So last row would not be acceptable.
Does anyone have any idea?
As noted, you could choose all 3 as a PK. Or you can even create a unique index on all 3 columns. These two ideas are thus code free.
Last but least, you could use a Before change macro,and do a search (lookup) in the table to check if the existing record exists. So far, given your information, likely a unique index is the least effort, and does not require you to change the PK to all 3 columns (which as noted is a another solution).
So, you could consider a before change macro. And use this:
Lookup a Record in MyTable
Where Condition = [z].[Field1]=[MyTable].[Field1] And
[z].[Field2]=[MyTable].[Field2] And
[z].[ID]<>[MyTable].[ID]
Alias Z
RaiseError -123
Error Description: There are other rows with this data
So, you can use a data macro, use the before change table macro. Make sure you have the raise error code indented "inside" of the look up code. And note how we use a alias for the look up, since the table name (MyTable) is already in context, and is already the current row of data, so we lookup using "z" as a alias to distinguish between the current row, and that of lookup record.
So, from a learning point of view, the above table macro can be used, but it likely less work and effort to simply setup a uniquie index on all 3 columns.

MySQL: Show all rows with same column value one after the other with the column value appearing only once

I have a table with columns:
ResourceId | Reason
I have 4 rows with values as follows
2884 | irrelevant
3441 | irrelevant
2884 | incorrect
1234 | incorrect
I want the data to appear something like this:-
2884 | irrelevant
| incorrect
3441 | irrelevant
1234 | incorrect
i.e. I want all the rows with similar ResourceId to appear together as a group but I only want to display the ResourceId for the first row. How can I write a query for this?

mysql table field values are hidden - why?

I am seeing this behavior on Windows 7 - mysql v5.6.17. When I try to view table records, the field with auto incrementing primary key (here it is the column with 'id') do not show values in all rows, but those values actually were populated after loading them from a data file. My initial thought was some of the values in ID column were missing, but they are not!
If I query individual row, then it shows the value in id column. Is this a normal behavior? Is there a better way to display table records?
Please see the image enclosed below.
The data certainly appears corrupted.
An 'uncorrupted' result might look like this...
+----+-------------+-----+-----+-------+
| id | PlateNumber | Row | Col | Orf |
+----+-------------+-----+-----+-------+
| 1 | 1 | A | 1 | Empty |
| 2 | etc... | | | |

Mysql where in multiple rows

I have this problem.
One table with.
id | routename | usersid |
1 | route 1 | 1,2,3,5 2 |
2 | route 2 | 5,20,15 3 |
4 | route 4 | 10,15,7,5 |
I need, search ej. userid 5 in colum usersid... but I have no idea how to do, because there are multiple rows.
If you cannot change the schema then you will have to use the REGEXP operator to match on a regular expression. For example
where column REGEXP '(^|,)5(,|$)'
This matches the number 5 either at the beginning or end of the field or surrounded by commas (or any combination thereof), to avoid matching other numbers like 15, 55 or 1234567890.
If the table is large this will perform very slowly as it will require a full table scan
You might be looking for FIND_IN_SET().
select * from Table1
WHERE FIND_IN_SET(5,usersid)
SAMPLE FIDDLE

show by example: row vs field?

Various documents define row as being synonymous with record. Unfortunately, a record can be a list or a single item. All the same, a row usually contains more than one item but is sometimes called "a single entry".
A field can be a container (for example, in html), which could be considered a place to input one item, or it could be considered a place where many items are entered (albeit on different occasions, sometimes).
It sure would be nice if someone could put it in simple terms. For example, a row is the result of a single-item, single-field entry via an insert statement. A field represents all rows and intersects a column.
Can anybody provide a clear answer because google just isn't cutting it. Thank you.
Edit:
In excel it sure is cut-and-dry. Column is all horizontal. Row is all vertical. Cell is a row-column pair; a single entry. Even though relational database languages are like working with multiple spreadsheets (tables), the column, row, cell approach seems to make the most sense.
I am looking at various different explanations that don't seem to agree with one another in the answers. Can we operationally define the terms for the tutorial I am presently working on, which is not clear? Link: http://zetcode.com/databases/sqlitetutorial/introduction/#about
If this is a table...
O--O-------------O-------------O
|ID| my_col_1 | my_col_2 |
O--O-------------O-------------O
|0 | fskdjfh | jfkhgdkfj |
|1 | NULL | hfkjsdh |
|2 | jfkdhsdkjh | NULL |
|3 | fdfhkjh | NULL |
|4 | NULL | NULL |
O--O-------------O-------------O
This is a row...
|0 | fskdjfh | jfkhgdkfj |
And this is a field...
| jfkhgdkfj |
Hows that?
Imagine you have to describe many aspect of the same thing. You have to choose which aspects you want to take care of: these are the columns of your table. For each of the column you can choose the data type to represent (numeric, String, ...). The column could be also a composite data type (ex: date) or a reference to another object.
The description of an object consists in all the values contained in the columns relative to that object: this is the row/record (the two terms have the same meaning in ER databases).
The field is the value assumed by a column--let's say that it is a cell in a table. It is part of the row, but it may have no sense outside the context provided by the row and the columns.
Maybe the confusion is due to the fact that to simplify the notation, the term field is used as the term column. When you see a query like "select * from foo where somefield=something" it means that you select the rows in which the field relative to the column "somefield", assumes the value "something".
This definition is ok also with HTML fields. A field of a form is the place where you enter the value the column will have in your case, that means, in the row that represents you.
One row/record, one column/field:
+---+
| x |
+---+
One row/record, three columns/fields:
+---+---+---+
| x | y | z |
+---+---+---+
Three rows/records, one column/field:
+----+
| x1 |
+----+
| x2 |
+----+
| x3 |
+----+
Three rows/records, three columns/fields:
+----+----+----+
| x1 | y1 | z1 |
+----+----+----+
| x2 | y2 | z2 |
+----+----+----+
| x3 | y3 | z3 |
+----+----+----+
fields or columns are defined with the table, and are the part of table structure, they hold information vertically. they describe the records or rows in the table.
Example: name, age, salary etc.
Rows or records are the real data that is stored in the table, these records are the actual information. one horizontal row represent one record.
Example: 'John', 23, 23000.00