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

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

Related

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

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.

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:

PowerBI and SharePoint lists: How do I count the number of rows with the PID value equal to each row's UID (the 3rd column needs the formula)

I have a table below, and I need to calculate the last column as a custom measure/custom column. I'm grateful for any advice concerning the formulae. Please note this is a single table. The last column counts the number of rows which have as PID, the respective row's UID.
Please note, I am using SharePoint lists so addressing the ID column will be done via: 'SharePoint list name'[Id] which is the standard syntax when calling a SharePoint list column.
ID PID Count rows
1 2
2 1 1
3 1 0
4 0
5 2 0
Many thanks for considering my request.
I am using Power BI Desktop 2.83.
I found the answer:
Create a second identical SharePoint list and use the below.
Additional column =
    calculate (
        COUNTROWS('SharePoint list (replica)'),
        FILTER('SharePoint list (replica)','SharePoint list (replica)'[PID]='SharePoint list'[ID])
    )

DAX Power BI Conditional filtering

Sample file
The column c of a table T can have the values 1, 2 or 3. I want to filter the table such as when the user selects value 1 nothing is filtered. When the selected value is 2 then show only the rows with the c column containing the value 2 or the value 3 not the value 1 and finally if the selected value is 3 then show only those rows containing 3 in the c column. The slider or a plain filter must be single selection not multi because otherwise it would violate one of the user's business rule.
Selected Show
1 all rows
2 rows with 2 or 3
3 only rows with 3
I tried to create columns and to create measures but I can't get anywhere. Any directions?
I agree that the disconnected table might be the best workaround here. I hope this solution will work with your actual file.
Step 1 - create a new disconnected table
FilterC = DISTINCT(T[c])
Step 2 - make sure that your slicer is sourced from the new table (FilterC)
Step 3 - create a measure that will return 1 for rows that we want to see, and 0 for rows that we want to hide:
mFilter =
var Filter_C = SELECTEDVALUE(FilterC[c])
var Row_C = SELECTEDVALUE(T[c])
return
SWITCH(
Filter_C,
"1", 1,
"2", IF(OR(Row_C = "2", Row_C = "3"), 1, 0),
"3", IF(Row_C = "3", 1, 0)
)
Step 4 - add this measure to the table, or even table filters will suffice.
Step 5 - start switching the values!
First you need to set it to a number column.
Second, you could write complex measures and use a disconnected table, but the best option is to use the correct slicer. There is a Greater than or Equal To option.

How to create new column in power bi using given string match condition in first column and get value from another column, make new column?

My table is as follow
Col1 Col2
11_A 9
12_B 8
13_C 7
14_A 6
15_A 4
The table we need after the query
Col1 Col2 Col3
11_A 0 9
12_B 8 0
13_C 7 0
14_A 0 6
15_A 0 4
My query is
Col3 =
LEFT( 'Table'[Col2],
SEARCH("A", 'Table'[Col1], 0,
LEN('Table'[Col1])
)
)
Go to the query designer Add Column > Custom Column and use the following expression:
Update
You need two expressions (two new columns) for this:
One is:
'Your Column3
=if Text.Contains([Col1], "A") = true then [Col2] else 0
And the second:
'Your Column2
=if Text.Contains([Col1], "A") = false then [Col2] else 0
There are many ways to solve this,
Another easy way I like to do this with no-coding is to use Conditional Columns:
In PBI select Power Query Editor
Select your table on the edge of the screen
Select Add Column tab
Select Conditional Columns...
Name your column
Enter your condition as in the picture
You can add several conditions if you like
Don't forget to format your column to numeric if needed.
see picture
Adding columns using Conditional Column