Informatica : Count the number of rows based on sequence of number - informatica

I have table where source has 1 column, like below. for example, column name is A and I have set of records in the source.
A
1
1
1
2
2
3
I want to populate two columns in target, Say columns are A and B.
Column A in the Target has same values as in source and column B has count
A B
1 1
1 2
1 3
2 1
2 2
3 1
Can someone please explain how can i achieve this.
Thanks in advance

If source is a dbms like oracle, you can use source qualifier overwrite sql like below. Use row number and partition by to generate sequence for every A.
Select
A, row_number() over(partition by A order by A) as B
From mytable
If you're looking for infomatica only solution then this is how you can do it.
Sort the data by column A
Use ex transformation, create one in/out two var, and one out port.
We are going to compare first val with prev val, if they r same, add 1to the sequence else start from 1 again.
A in/out
v_B = iif (A=prev_A, v_B +1, 1)
prev_A=A
o_B =v_B
Link A and o_B to the target.

Related

PowerBI - calculated field to check for dissimilar items in a semi-colon separated list in a row cell

I am using PowerBI desktop to create visualization from data source (a table in excel sheet) and I need to create a calculated field from one of the columns from the data. One of the columns in my data table is as follows:
Technology
A
A;A
B;B;B
C;D;C
A;A;B
B;B;B
D;D
A;
;
;;
I want to create a new column of type Boolean that outputs 1 when only one unique item is in a row of column and 0 when items in the semi-colon separated list are not unique. Like this:
Technology
New Column
A
1
A;A
1
B;B;B
1
C;D;C
0
A;A;B
0
B;D;B
0
D;D
1
A;
1
;
0
;;
0
How can I do this in PowerBI desktop?
EDIT: Updated requirements to test three more cases. (last three rows)
Add a new column and type in the following:
if List.Count( List.RemoveItems( List.Distinct( Text.Split([Technology],";")), {""})) = 1 then 1 else 0

Power BI - CRUD analysis how?

I have 2 data sources - Source 1 ( SharePoint List ) & Source 2 ( Cloud Source ). I bring both into Power BI. They each have a key to identify a unique instance of a record.
In Power BI I have been asked to identify the New Inserts / Deletes and Updated Records.
So is there an easy way of doing this?
Table 1
Key Column 1 Column 2 Column 3
Table 2
Key Column 1 Column 2 Column 3
You can use Merge queries transformation in Power Query Editor to do that. Left Anti and Right Anti join kinds will give you the rows that exists only in the first or second data source. Inner will give you the rows that exists in both (based on their key value) and later you can compare the other columns to decide are they modified or not.
Lets assume there are two data sources, as follows:
Source 1
Key
Column 1
Column 2
Column 3
1
initial value
initial value
initial value
2
initial value
initial value
initial value
3
initial value
initial value
initial value
Source 2
Key
Column 1
Column 2
Column 3
1
initial value
initial value
initial value
2
modified value
initial value
initial value
4
initial value
initial value
initial value
1 exists in both sources and is not modified;
2 exists in both sources but is modified (Column 1 has different values);
3 exists only in Source 1;
4 exists only in Source 2.
In Power Query Editor, in Home tab of the ribbon, in Combine group, click on Merge Queries -> Merge Queries as New, select Source 1 as the first source, Source 2 as the second source, set the join kind to be Left Anti and make sure Key columns in both sources are selected:
This will give you the rows, that exists only in Source 1, i.e. only 3 (and remove the columns from Source 2 there, because they are not needed):
Do the same merge again, but swap the sources:
to get the rows, that exists only in Source 2, i.e. 4:
And then do it again, but this time set the join kind to be Inner:
Click on the button in the header of Source 2 column and add all the columns except Key and add a conditional column (Add Column -> General -> Conditional Column) as follows (note, that the screenshot is incorrect - the third comparison should be between Column 3 and Source 2.Column 3):
It will tell you is this row modified (2) or not (1):
If you want you can click the button in the header of the custom column and filter the result to show only the rows, where the value is Modified, which will leave only 2 in the result:

Big Query Select rows in between two values

I'm trying to select rows in between two values using big query.
Here the table is:
ID Group values
1 A 10I
1 B 20I
1 C 30I
1 D 40I
1 E 50I
1 F 60I
1 G 70I
1 H 80I
1 I 90I
Here I need to select rows from Group C to G.
The code i'm using is:
select * from data
where Group >= 'C' and Group <='G'
The above code gave no results.
Also i tried:
select * from data
where Group between 'C' and 'G'
This also returned no results.
Someone please provide a solution.
This is because "Group" is a reserved word (the GROUP BY): BQ expects you to group something and didn't understand that here it is the name of a column. To make BQ understand just as backslashes:
SELECT *
FROM data
WHERE `Group` BETWEEN "C" AND "G"

Concatenating row values in Athena Aws

I've 2 cols lets say id and values. I want to concatenate values grouped by id col.
for eg.
I've
ID Values
1 a
1 b
2 a
2 b
I need the output as
ID Values
1 a,b
2 a,b
You can use an array_agg followed by an array_join
select id, array_join(array_agg(values),',') from table group by 1
The array_agg will give you an array of all values with the same id, and the array_join will concatenate them into a string. See the docs.

Generating a List in M Query

I am trying to generate a list using M Query, but instead of generating a list starting from a specific, number, I want the number to start at 1 and then add 1 for every row on another table.
So for example, if I have:
Tbl1
Col1
A
B
C
D
D
I want to generate
Tbl2
Col1
1
2
3
4
5
I want the number to start at 1 and then add 1 for every row on another table.
if I understand your correctly, here it is:
={1..Table.RowCount(Tab1)}