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

Calcular la primera ocurrencia en una columna basada en 2 criterios

Estoy tratando de calcular la primera vez que el evento expiró en función del índice más antiguo.

--Evento----Index----Status----Primera ocurrencia caducada--
Evento11válido
Evento12válido
Evento13caducadoPrimero
Evento14caducado
Evento15caducado
Evento16caducado
Evento17caducado
Evento21caducadoPrimero
Evento22caducado
Evento31válido
Evento32caducadoPrimero
Evento33caducado
Evento34caducado

Ya casi llego, pero no sé a dónde llevarlo desde aquí:

First Occurrence Expired = CALCULATE(MAX(datasource[Index]),
FILTER(datasource,datasource[Event] = EARLIEST(datasource[Event]) &&
'datasource'[Index] = EARLIEST('datasource'[Index]) && 
datasource[Status] = "Expired"))

Esto me da el índice correcto.

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

No @WorkHard,

si te entendí entonces esta puede ser la solución:

14-05-_2021_22-59-23.png

First Occurance Expired = 
VAR _MinIndex = CALCULATE(MIN('Table'[Index]), FILTER(ALLEXCEPT('Table','Table'[Event]),'Table'[Status] = "Expired"))
RETURN
    IF(MIN('Table'[Index]) = _MinIndex , "First" , "")

Con amables saludos desde la ciudad donde la leyenda del 'Pied Piper de Hamelin' está en casa
FrankAT (Orgulloso de ser un Datanaut)

View solution in original post

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

No @WorkHard,

si te entendí entonces esta puede ser la solución:

14-05-_2021_22-59-23.png

First Occurance Expired = 
VAR _MinIndex = CALCULATE(MIN('Table'[Index]), FILTER(ALLEXCEPT('Table','Table'[Event]),'Table'[Status] = "Expired"))
RETURN
    IF(MIN('Table'[Index]) = _MinIndex , "First" , "")

Con amables saludos desde la ciudad donde la leyenda del 'Pied Piper de Hamelin' está en casa
FrankAT (Orgulloso de ser un Datanaut)

súper confundido.

El regreso de

MIN('Table'[Index])

(última línea en su código) siempre está devolviendo 1 para mí.

Se corrigió quitando MIN del cálculo. Es posible que estuvieras creando una medida y estoy usando una columna de cálculo.

First Occurance Expired = 
VAR _MinIndex = CALCULATE(MIN('Table'[Index]), FILTER(ALLEXCEPT('Table','Table'[Event]),'Table'[Status] = "Expired"))
RETURN
    IF('Table'[Index] = _MinIndex , "First" , "")

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.