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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Syndicate_Admin
Administrator
Administrator

Agrupe por una columna y seleccione solo las filas donde aparezcan los valores de otra columna en ambas listas

Estoy buscando encontrar un recuento distinto de la columna 1 donde, al agrupar por columna 1, los valores de la columna 2 se pueden encontrar en dos listas.

Lista 1 = {1, 2}

Lista 2 = {X, Y}

A4
A2
AX
B3
BZ
C1
CY
CQ
D2
D

X

Aquí el recuento esperado sería 3, porque:

Donde Columna 1 = A, la Columna 2 contiene valores {4, 2, X}. Como 2 está en {1, 2} y X está en {X, Y}, se cumplen los criterios

Donde Columna 1 = C, Columna 2 contiene valores {1, Y, Q}. Como 1 está en {1, 2} e Y está en {X, Y}, se cumplen los criterios

Donde Columna 1 = D, Columna 2 contiene valores {2, X}. Como 2 está en {1, 2} y X está en {X, Y}, se cumplen los criterios

No estoy seguro de cómo crear una medida en Power BI que logre esto. ¡Cualquier ayuda sería muy apreciada!

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

Hola

Syndicate_Admin
Administrator
Administrator

¿Por qué tendría que ser una medida?

Esta es una versión de Power Query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTJRitWBsIzgrAgwywnIMoazosAsZyDLEM6KhLMCwSwXuCkuEFNiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Test", each List.Contains({"1","2"},[Column2]) or List.Contains({"X","Y"},[Column2])),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Test] = true)),
    #"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Column1"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Other Columns")
in
    #"Removed Duplicates"

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.