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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Fabric Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors