Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hi all!
I need to create a script where count the rows in table_1 and table_2, then i need to compare the two tables and show the differences.
For example:
Table_1
| ID | Name | Date | City |
|---|---|---|---|
| 10001 | Name_1 | 01/01/2016 | NY |
| 10011 | Name_2 | 10/12/2016 | WA |
| 10101 | Name_3 | 11/11/2015 | NY |
| 10101 | Name_4 | 00/00/0000 |
Table_2
| ID | Name | Date | City |
|---|---|---|---|
| 10002 | Name_6 | 01/01/2016 | NY |
| 10016 | Name_7 | 10/11/2016 | AL |
| 10101 | Name_3 | 11/11/2015 | NY |
| 10101 | Name_4 | 00/00/0000 | |
| 20011 | Name_23 | 02/02/2014 | WA |
I need two tables as a result:
| Table | Rows |
|---|---|
| Table_1 | 4 |
| Table_2 | 5 |
and a table with the rows dont match
| ID | Name | Date | City | Table |
|---|---|---|---|---|
| 10001 | Name_1 | 01/01/2016 | NY | Table_1 |
| 1011 | Name_2 | 10/12/2016 | WA | Table_1 |
| 20011 | Name_23 | 02/02/2014 | WA | Table_2 |
Thanks!!!
First load the two table with a source indicator
LOAD ID,
Name,
Date,
City,
'Table1' as Source
FROM .... table 1
Concatenate
LOAD ID,
Name,
Date,
City,
'Table2' as Source
FROM .... table 2
For the first result, use Source a the dimension and Count(ID) as the expression.
For the second, use ID, Name, Date, City as dimensions, and If(Count(Distinct Source) = 1, 1, 0) as the expression. Ensure suppress zeroes is checked on the presentation tab and hide the expression column.