Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Add custom columns to table

Hi everyone,

I have 2 tables "Table1"

and "Table2"


I need to create a new column in Table1 with the value "employee_name" in Table2 satisfying the following conditions:
- Table1 [id] = Table2 [employee_id]
- status = "status1"
- log_id is the smallest id value

 

Please help me, thanks you.

1 Reply

  • camargos88's avatar
    camargos88
    Community Champion

    Hi Anonymous ,

     

    Try this code for a new column:

    Column =
    VAR _minLogID = CALCULATE(MIN('Table (2)'[log_id]); FILTER('Table (2)'; 'Table (2)'[employee_id] = EARLIER('Table'[id]) && 'Table (2)'[status] = "status1"))
    RETURN CALCULATE(DISTINCT('Table (2)'[employee_name]); FILTER('Table (2)'; 'Table (2)'[log_id] = _minLogID))