Forum Discussion
Help with calculated column
- Anonymous5 years ago
According to my understanding, you want to get the last [sem_Epi] fromtable1 when [Fecha_Inscripcion]is before [Fec_Fin_Sem], right?
As @Vera_33 suggest, you can use the MINX() and LOOKUPVALUE() functions to do this,
Sem_Epi = VAR _date = [Fecha_Inscripcion] VAR _near = MINX ( FILTER ( 'Table of Semanas_Epidemiologica', 'Table of Semanas_Epidemiologica'[Fec_Fin_Sem] >= _date ), [Fec_Fin_Sem] ) RETURN LOOKUPVALUE ( 'Table of Semanas_Epidemiologica'[Sem_Epi], [Fec_Fin_Sem], _near )Or to make it easier to understand, use the following formula:
Sem_Epi 2 = VAR _date = [Fecha_Inscripcion] VAR _near = CALCULATE ( MIN ( 'Table of Semanas_Epidemiologica'[Fec_Fin_Sem] ), FILTER ( 'Table of Semanas_Epidemiologica', 'Table of Semanas_Epidemiologica'[Fec_Fin_Sem] >= _date ) ) RETURN CALCULATE ( MAX ( 'Table of Semanas_Epidemiologica'[Sem_Epi] ), FILTER ( 'Table of Semanas_Epidemiologica', 'Table of Semanas_Epidemiologica'[Fec_Fin_Sem] = _near ) )The final output is shown below:
You could take a look at the pbix file here.
Best regards
Eyelyn Qin
If this post helps, then consider Accept it as the solution to help other members find it faster.
According to my understanding, you want to get the last [sem_Epi] fromtable1 when [Fecha_Inscripcion]is before [Fec_Fin_Sem], right?
As @Vera_33 suggest, you can use the MINX() and LOOKUPVALUE() functions to do this,
Sem_Epi =
VAR _date = [Fecha_Inscripcion]
VAR _near =
MINX (
FILTER (
'Table of Semanas_Epidemiologica',
'Table of Semanas_Epidemiologica'[Fec_Fin_Sem] >= _date
),
[Fec_Fin_Sem]
)
RETURN
LOOKUPVALUE ( 'Table of Semanas_Epidemiologica'[Sem_Epi], [Fec_Fin_Sem], _near )
Or to make it easier to understand, use the following formula:
Sem_Epi 2 =
VAR _date = [Fecha_Inscripcion]
VAR _near =
CALCULATE (
MIN ( 'Table of Semanas_Epidemiologica'[Fec_Fin_Sem] ),
FILTER (
'Table of Semanas_Epidemiologica',
'Table of Semanas_Epidemiologica'[Fec_Fin_Sem] >= _date
)
)
RETURN
CALCULATE (
MAX ( 'Table of Semanas_Epidemiologica'[Sem_Epi] ),
FILTER (
'Table of Semanas_Epidemiologica',
'Table of Semanas_Epidemiologica'[Fec_Fin_Sem] = _near
)
)
The final output is shown below:
You could take a look at the pbix file here.
Best regards
Eyelyn Qin
If this post helps, then consider Accept it as the solution to help other members find it faster.