This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hola, quiero marcar la primera aparición de cuentas en función de una fecha, con un filtro (solo debe considerar si ACTIVE=yes), y si hay duplicados necesito elegir solo uno de ellos (al azar).
El trabajo esperado es el siguiente
| Cuenta | CreateDate (Fecha de creación) | Activo | FirstOccurrence |
| X | 15-Mar-24 | Sí | 1 |
| X | 15-Mar-24 | Sí | 0 |
| Y | 14-Mar-24 | No | 0 |
| Y | 15-Mar-24 | Sí | 1 |
Hola @dorukturkoglu ,
En función de la muestra y la descripción que proporcionó, pruebe los siguientes pasos:
Mi muestra:
1.Puede considerar la posibilidad de agregar una columna de índice en Power Query.
El código específico es el siguiente.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WilDSUTI01fVNLNI1MgGyI1OLlWJ1CIibYYpHgsRNEOJ++QhhLMZEYjMmFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Account = _t, CreateDate = _t, Active = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Account", type text}, {"CreateDate", type date}, {"Active", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Account"}, {{"Count", each Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type)}}),
#"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"CreateDate", "Active", "Index"}, {"CreateDate", "Active", "Index"})
in
#"Expanded Count"
2.Utilice el siguiente código para crear una columna calculada.
FirstOccurrence =
VAR CurrentAccount = 'Table'[Account]
VAR CurrentDate = 'Table'[CreateDate]
VAR MinDate =
CALCULATE (
MIN ( 'Table'[CreateDate] ),
FILTER (
ALL ( 'Table' ),
'Table'[Account] = CurrentAccount
&& 'Table'[Active] = "Yes"
)
)
VAR MinIndex =
CALCULATE (
MIN ( 'Table'[Index] ),
FILTER (
'Table',
'Table'[Account] = CurrentAccount
&& 'Table'[CreateDate] = MinDate
)
)
RETURN
IF ( 'Table'[CreateDate] = MinDate && 'Table'[Index] = MinIndex, 1, 0 )
El resultado es el siguiente.
¿Es este el resultado que esperas?
Para más detalles, sírvase encontrar el archivo adjunto.
Saludos
Yulia Yan
Si esta publicación ayuda, considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.