Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
avsparry
Frequent Visitor

Buscar por palabra clave en otra tabla y varias agrupaciones

Hola

Estoy buscando buscar una columna de tabla (texto) con palabras clave de otra tabla y vincularla a esa nueva tabla, esencialmente creando agrupaciones útiles a partir de las palabras clave. He encontrado varios ejemplos útiles en este foro, pero ninguno llega al fondo de mi problema. Usaré un ejemplo de la comunidad.

Keyword_FACT

Palabra claveTipo
MóduloContenido
SeminarioContenido
ClaseContenido
LecturaContenido
LecciónContenido
AcadémicoPersonal
AdministradoresPersonal
PersonalPersonal
ProfesoresPersonal

Reference_FACT

GéneroDepartamentoComentario
MClásicosLas conferencias y las lecciones son muy buenas.
MBiología
MClásicosMe encanta el personal.
FClásicosMe divertí.
MFísicaLos académicos son geniales
FBiologíaConferencias agradables
MClásicosEl personal ofrece grandes seminarios

uare DAX

Keyword = 
CONCATENATEX(
    'Keywords_FACT',
    IF(
        SEARCH('Keywords_FACT'[Keyword], 'Reference_FACT'[Comment],,999) <> 999,
        'Keywords_FACT'[Keyword] & " ",
        ""
        )
)

Y

Type = 
CONCATENATEX(
    'Keywords_FACT',
    IF(
        SEARCH('Keywords_FACT'[Keyword], 'Reference_FACT'[Comment],,999) <> 999,
        'Keywords_FACT'[Type] & " ",
        ""
        )
)

resultados en

GenderDepartment CommentKeywordType

GéneroDepartamentoComentarioPalabra claveTipo
MClásicosLas conferencias y las lecciones son muy buenas.clase de conferenciacontenido de contenido
MBiología
MClásicosMe encanta el personal.PersonalPersonal
FClásicosMe divertí.
MFísicaLos académicos son genialesAcadémicoPersonal
FBiologíaConferencias agradablesLecturaContenido
MClásicosEl personal ofrece grandes seminariospersonal del seminariopersonal de contenido

Así que ahora puedo usar la columna Tipo para filtrar mis datos sin embargo, si tengo varias palabras clave en diferentes "tipos" me desengancho (por ejemplo, la fila final en el ejemplo anterior). No quiero crear filas adicionales (no quiero duplicar ningún dato).

Me gustaría filtrar por contenido o personal y tener la fila final disponible en ambos

Si alguien puede pensar en una solución útil sería genial.

(como un aparte creo que podría ser útil convertir el DAX en la consulta de energía si eso también se pudiera hacer)

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

Hola, @avsparry

Según su descripción, creé datos para reproducir su escenario. El archivo pbix se adjunta al final.

Puede crear una medida como se indica a continuación.

Visual Control = 
var x = 
COUNTROWS(
    FILTER(
        DISTINCT('Table'[Type]),
        CONTAINSSTRINGEXACT(MAX(Reference_FACT[Type]),[Type])
    )
)
return
IF(
    ISFILTERED('Table'[Type]),
    IF(
        x>0,
        1,0
    ),
    1
)


Por último, debe colocar la medida en el filtro de nivel visual para mostrar el resultado.

x2.png

x.png

Saludos

Allan

Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

View solution in original post

9 REPLIES 9
Syndicate_Admin
Administrator
Administrator

Hola, @avsparry

Según su descripción, creé datos para reproducir su escenario. El archivo pbix se adjunta al final.

Puede crear una medida como se indica a continuación.

Visual Control = 
var x = 
COUNTROWS(
    FILTER(
        DISTINCT('Table'[Type]),
        CONTAINSSTRINGEXACT(MAX(Reference_FACT[Type]),[Type])
    )
)
return
IF(
    ISFILTERED('Table'[Type]),
    IF(
        x>0,
        1,0
    ),
    1
)


Por último, debe colocar la medida en el filtro de nivel visual para mostrar el resultado.

x2.png

x.png

Saludos

Allan

Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

parry2k
Super User
Super User

@avsparry aquí tienes, solución adjunta. Creo que hay algunas cosas donde puedo mejorar, pero por ahora, está bien. Creo que tengo que pasar más tiempo trabajando con List.Intersect para una solución más elegante.

Consulta mi última entrada de blog Año-2020, Pandemia, Power BI y más allá para obtener un resumen de mis versiones favoritas de las características de Power BI en 2020

Me gustaría elogios si mi solución ayudara. 👉 Si puedes dedicar tiempo a publicar la pregunta, también puedes hacer esfuerzos para dar Felicitaciones a quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!

Visítenos en https://perytus.com, su ventanilla única para proyectos/formación/consulta relacionadas con Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k hay de todos modos para expandir esto para buscar en dos columnas?

Sólo otro comentario. He intentado usar esta solución en mi conjunto de datos real (que es mucho más grande) y es significativamente más lento que usar DAX. ¿Tiene este problema también?

Me temo que no podré enviarle este conjunto de datos

No @parry2k

Esto funciona para mí y ordena mover el problema a la consulta de energía, ¿tiene algún consejo sobre cómo filtrar por tipo ahora lo tenemos en este formato?

Salud

ps Me gusta esta solución, voy a tratar de conseguir mi cabeza alrededor de todos los bits, para cualquier persona que no quiere descargar el pbix, es necesario crear esta función y luego utilizar en addcolumn en su tabla de datos.

(searchText as text,   ignoreCase) =>
let
    SplitSearchTextToList = Text.Split(searchText," "),  //split search text by space
    searchList = Table.Column(Keywords_FACT, "Keyword"), //get list of keywords
    typeList = Table.Column(Keywords_FACT,"Type"),       //get list of keywords type

    SearchPos = List.Transform(SplitSearchTextToList,each 
    List.PositionOf( searchList, _, 0,(searchText,searchValue) => let newsearchText = if ignoreCase then Text.Lower(searchText) else searchText, newsearchValue = if ignoreCase then Text.Lower(searchValue) else searchValue  in Text.Contains(newsearchValue,newsearchText))), //search each search word in the keyword list and get the list of search position

    RemovePos = List.RemoveItems(SearchPos,{-1}), //remove not found search position 
    GetKeywords = Text.Combine(List.Transform(RemovePos,each searchList{_}),","), //get list of keywords based on the search position
    GetType = Text.Combine(List.Transform(RemovePos,each typeList{_}),","), //get list of type based on the saarch position
    #"Keywords and Type" = [Keywords=GetKeywords,Type=GetType] //create a record of keyword and type
in
    #"Keywords and Type"

parry2k
Super User
Super User

@avsparry también puede compartir el archivo de Excel que utilizó en pbix ya que voy a hacer la transformación en PQ y necesita archivo de datos.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@avsparry Creo que será fácil de hacer en PQ que DAX y tengo que volver atrás y mirar una de mis soluciones donde hice algo similar. Puede colocar estos datos de ejemplo en un archivo pbix y compartirlos con una unidad drive/google.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

No @parry2k

gracias por echar un vistazo a esto, aquí hay un enlace al ejemplo https://www.dropbox.com/s/qgjslguu4v1bgsl/communityexample.pbix?dl=0

He estado tratando de implementar algo en PQ, pero no soy lo suficientemente bueno en ello. Realmente interesado en ver su solución.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.