Forum Discussion

plugwater's avatar
plugwater
Frequent Visitor
2 years ago

Fetch the right value based on condition

Hi,

 

I need to get the OutputID based on an Indicator in another table from the same group.

 

Can this be done through a DAX formula ?

 

Table 1 : OutputID is field I need to fetch from Table 2.

Table 2 has the grouping in the PrimaryKey and in that group, Valid column if it is X then that entry should be copied to AlternateID.

 

ID_2 is the link between the two tables.

Thanks a lot in advance. 

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi plugwater 

     

    For your question, here is the method I provided:

     

    Make sure you have the correct relational connections between your tables.

     

     

    Create a column.

     

    OutputID = 
    VAR _Valid = CALCULATE(
        MAX('Table2'[ID_2]),
        FILTER(
            ALL('Table2'),
            'Table2'[ID_2] = EARLIER('Table1'[ID_2]) && 
            'Table2'[Valid] = "X"))
    RETURN
    _Valid

     

    Here is the result.

     

     

    Regards,

    Nono Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • plugwater's avatar
      plugwater
      Frequent Visitor

      Thanks for this.

       

      This does not work. I applied the formula and I would like the OutputID in all the rows.

       

      I am not sure if the MAX condition works here.