Forum Discussion
Condicional con campos same/diff.
Puede hacerlo en Power Query.
Comenté los pasos para explicar lo que está pasando.
Espero que esto ayude
let
//copied in source data from table on web
Source =
Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs7JTM0rUXBU0lEyNDAwMrQwd3I1MATyvPIz8hSCczNLMoAct8TiEoWQosTkbKVYHVyaMknW5RoMtsonNakoP0/BKzE3tRjINVJwrkzOScWjB2STT2l2ooJLfl5yZjJBPW5BYHuCM3PKMhMVwhKrCktTq4hxIEhjJiGdsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t, CUID = _t, #"Project Manager" = _t, Method = _t]),
changeDataTypes =
//set data types to text
Table.TransformColumnTypes(
Source,
{{"Customer", type text}, {"CUID", type text}, {"Project Manager", type text}, {"Method", type text}}
),
//add a column that tests for 'i' at the end of CUID
addIntegrationTest =
Table.AddColumn(
changeDataTypes,
"Integration",
each if Text.EndsWith([CUID], "i") then "Yes" else "No"
),
//add a column that combines 'Customer', 'CUID' and 'Project Manager'
//removes the 'i' from the CUID if it is present
addAmendCUID =
Table.AddColumn(
addIntegrationTest,
"amendCUID",
each if Text.EndsWith([CUID], "i") then [Customer]&Text.BeforeDelimiter([CUID], "i")&[Project Manager] else [Customer]&[CUID]&[Project Manager]
),
//add a column that contains a list of 'amendCUID' values that have 'Integration' equal to 'Yes'
addYesList =
Table.AddColumn(
addAmendCUID,
"yesList",
each Table.Column( //turns the 'amendCUID' column into a list
Table.SelectRows( //selects rows from the table that have 'Integration' equal to 'Yes'
addAmendCUID,
each [Integration] = "Yes"
),
"amendCUID")
),
//add a column that counts the instances of the 'amendCUID' value in the list of all 'amendCUID' values
addAmendCUIDCount =
Table.AddColumn(
addYesList,
"countCUID",
(x)=> List.Count( //function that counts the number of times the current row 'amendCUID' value occurs
List.Select( //create a list that contains only values equal to the current row 'amendCUID' value
Table.Column( //create a list of all 'amendCUID' values
addYesList,
"amendCUID"
),
each _ = x[amendCUID]
)
)
),
//add a conditional column that displays 'Fast Track' if the current row 'amendCUID' value is in the 'yesList' and if 'countCUID' value is greater than 1
//'2 Cycle' is displayed if those conditions are not met
addMethod =
Table.AddColumn(
addAmendCUIDCount,
"Method2",
each if List.Contains([yesList], [amendCUID]) = true and [countCUID] > 1 then "Fast Track" else "2 Cycle"
),
//remove columns that are no longer needed
removeColumns =
Table.RemoveColumns(
addMethod,
{"Integration", "amendCUID", "yesList", "countCUID"}
)
in
removeColumns- Syndicate_Admin3 years agoAdministrator
HI Jgeddes
Gracias. Intentaré hacerlo siguiendo tus pasos.
Solo para aclarar, la columna "método" no existe en mi tabla. Fue solo para mostrar el resultado que quiero ver. Se incluyen el cliente, CUID y el gerente / coordinador del proyecto.
Para la siguiente parte:
let //copied in source data from table on web Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs7JTM0rUXBU0lEyNDAwMrQwd3I1MATyvPIz8hSCczNLMoAct8TiEoWQosTkbKVYHVyaMknW5RoMtsonNakoP0/BKzE3tRjINVJwrkzOScWjB2STT2l2ooJLfl5yZjJBPW5BYHuCM3PKMhMVwhKrCktTq4hxIEhjJiGdsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t, CUID = _t, #"Project Manager" = _t, Method = _t]),Realmente no entiendo el paso. ¿Necesito crear una columna personalizada y usar mi ruta de archivo?
- Syndicate_Admin3 years agoAdministrator
Dejé su columna de método en mi ejemplo solo para resaltar que se logró el mismo resultado. No lo usé de ninguna manera.
El paso 'Fuente' en el código de consulta es solo una copia de los datos que publicó en la web. No debería tener que realizar ningún cambio en el código fuente de consulta existente. Estarías buscando usar todo mi código pero excluyendo mi fuente. (Utilice su fuente.) Es probable que tengas que cambiar los nombres de columna en mi código para mathc los nombres de columna en tu código.- Syndicate_Admin3 years agoAdministrator
HI Jgeddes
Tratando de usar su fórmula agregando mi fuente, pero obtengo un error con respecto a Comma esperado.
¿Un consejo? gracias