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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
rhl94
Advocate III
Advocate III

Buscar ID en varias filas

Hola

Quiero una columna o medida calculada, que determine si se ha dado o no un tratamiento idéntico al mismo cliente antes, sin un período de 3 años.

Tengo las siguientes columnas:

Reclamación ? PersonID ? Tipo de tratamiento ? Fecha
1 1 2356 1-1-2020
2 1 2356 1-3-2018
3 2 2356 1-2-2020
4 2 2356 1-1-2016
5 3 2685 23-2-2017

En este caso, quiero una bandera en PersonID 1 como tratamiento idéntico(2353) ha estado dando más de una vez dentro del período de 3 años, mientras que PersonID 2 tiene más de 3 años entre el mismo tratamiento

6 REPLIES 6
amitchandak
Super User
Super User

Probar como nueva columna

if ( datediff(maxx(filter(table,table[PersonID]-arlier[PersonID] && table[Treatmenttype] ?arlier[Treatmenttype]) &&
table[Date] ?antes[Fecha]) ,tabla[Fecha],tabla[Fecha],año)< 3 ,"Sí","No")

az38
Community Champion
Community Champion

Hola @rhl94

tratar de una medida

Measure = 
var _isInCondition = CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[PersonID]=SELECTEDVALUE('Table'[PersonID]) && 'Table'[Treatmenttype]=SELECTEDVALUE('Table'[Treatmenttype]) && 'Table'[Date]< SELECTEDVALUE('Table'[Date]) && DATEDIFF('Table'[Date], SELECTEDVALUE('Table'[Date]),YEAR) < 4))
RETURN
if(_isInCondition>0,1,0)


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Parece que olvidé mencionar que la columna treatmenttype proviene de una tabla diferente para que el cliente (uno) al tratamiento (muchos).

Por lo tanto, la medida no funciona del todo. Si quito el filtro en Tratamiento, parece funcionar.

Comparta la estructura de ambas tablas.

Mariusz
Community Champion
Community Champion

Hola @rhl94

Prueba esta medida.

Measure = 
CALCULATE(
    IF( 
        COUNTROWS( 'Table' ) > 1, 
        DISTINCTCOUNT( 'Customer'[PersonID] ) 
    ),
    ALLEXCEPT( 'Table', 'Customer'[PersonID], 'Table'[Treatmenttype] ),
    DATESINPERIOD( 'Calendar'[Date], MAX( 'Calendar'[Date] ), -3, YEAR )
)

Saludos
Mariusz

Si este post ayuda,entonces por favor considere aceptarlo como la solución.

Por favor, siéntase libre de conectarse conmigo.
Linkedin

Parece casi funcionar, excepto que necesito filtrar por un tipo de tratamiento específico.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors