I have a table that looks like the one below.
Table I have
I want an output classifying the PART as either CLASS A or B. CLASS A and CLASS B should be created as two additional columns.
The conditions for classifications are:
-> IF Arrangement, Prefix and Range are the same, it will be classified as CLASS A and CLASS B, and the PART should be in both columns.
-> If the above condition is false, it will check the value in the TYPE column. If the type column contains CLASS A, then the respective PART should be in the CLASS A column. If the type column contains CLASS B, then the separate PART should be in the CLASS B column.
Here is the sample of the output I would need.
Table I want
So far, I have managed to get the below output but have not been able to merge the results into one row when the three columns are the same.
Results I got till now
Sample Data
Arrangements PREFIX RANGE PART TYPE
ARR1 1XJ 1-100 191123 TRANSMISSION CLASS A
ARR1 1XJ 1-100 299123 TRANSMISSION CLASS B
ARR1 9TC 1-100 191123 TRANSMISSION CLASS A
ARR2 5TJ 101-120 288123 TRANSMISSION CLASS B
Try this in M Advanced Editor
Table.AddColumn(previousStepName, "Text After Delimiter", each Text.AfterDelimiter([TYPE], " "), type text)
In the Query Editor (Transform Data), you can
Group by Arrangements
, Prefix
and Range
and use the ALL operation
Then add Custom Columns with the formula below for CLASS A
=try Table.SelectRows([Count], each Text.Contains([TYPE],"CLASS A"))[PART]{0} otherwise null
Count
column
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.