Forum Discussion
Condicional con campos same/diff.
Hola a todos
Tengo un archivo Excel con información del cliente, CUID (número único de cliente) + PM Nombre + método
CUID terminado con "i" significa integración. Los CUID pueden ser únicos y también puedo tener el mismo CUID que termina con "i".
Trato de encontrar una fórmula que diga si PM es el mismo trabajando con el CUID normal + Same CUID (terminando con "i") que Fast Track, de lo contrario 2 Cycle. Véase el cuadro siguiente.
| Cliente | .PART | Gerente de Proyecto / Coordinador | Método |
| Cliente A | 1002187BE01 | Juan Herrero | Vía rápida |
| Cliente A | 1002187BE01i | Juan Herrero | Vía rápida |
| Cliente A | 1002187ES01 | Lebron James | 2 Ciclo |
| Cliente A | 1002187ES01i | Heridas Doncic | 2 Ciclo |
| Cliente A | 1002187FR01 | Silvia Vázquez | Vía rápida |
| Cliente A | 1002187FR01i | Silvia Vázquez | Vía rápida |
¿Algún consejo? gracias
4 Replies
- Syndicate_AdminAdministrator
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_AdminAdministrator
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_AdminAdministrator
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.