Forum Discussion
dcor12
3 years agoFrequent Visitor
Calculated column pulling value from other table based on earliest date
See screenshots of sample data model and tables. The C_VALUE column is the calculated column I am attempting to create with expected results shown. C_VALUE should populate with th...
- Anonymous3 years ago
Hi dcor12 ,
You can create a calculated column as below in the table 'TABLE C' to get it, please find the details in the attachment.
C_VALUE = VAR _aids = CALCULATETABLE ( VALUES ( 'TABLE B'[A_ID] ), FILTER ( 'TABLE B', 'TABLE B'[C_ID] = 'TABLE C'[C_ID] ) ) VAR _mindate = CALCULATE ( MIN ( 'TABLE A'[A_STARTDATE] ), FILTER ( 'TABLE A', 'TABLE A'[A_ID] IN _aids ) ) VAR _minvalue = CALCULATE ( MIN ( 'TABLE A'[A_VALUE] ), FILTER ( 'TABLE A', 'TABLE A'[A_ID] IN _aids && 'TABLE A'[A_STARTDATE] = _mindate ) ) RETURN _minvalueBest Regards
Anonymous
3 years agoNot applicable
Hi dcor12 ,
You can create a calculated column as below in the table 'TABLE C' to get it, please find the details in the attachment.
C_VALUE =
VAR _aids =
CALCULATETABLE (
VALUES ( 'TABLE B'[A_ID] ),
FILTER ( 'TABLE B', 'TABLE B'[C_ID] = 'TABLE C'[C_ID] )
)
VAR _mindate =
CALCULATE (
MIN ( 'TABLE A'[A_STARTDATE] ),
FILTER ( 'TABLE A', 'TABLE A'[A_ID] IN _aids )
)
VAR _minvalue =
CALCULATE (
MIN ( 'TABLE A'[A_VALUE] ),
FILTER (
'TABLE A',
'TABLE A'[A_ID]
IN _aids
&& 'TABLE A'[A_STARTDATE] = _mindate
)
)
RETURN
_minvalue
Best Regards
dcor12
3 years agoFrequent Visitor
Thank you, this works beautifully!