Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Comparison operator saved in Cell - How to use?

Hi all,   I have two columns that I need to compare and the comparison operator is saved in a third column. I am not sure how to write the query to use the operator that is saved in the cells  ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous 

     

    Thanks for the reply from amitchandak , please allow me to provide another insight:

    I create a set of sample:

    Then add a calculate column:

    Column =
    SWITCH (
        TRUE (),
        'Table'[Value1] > 'Table'[Value2]
            && FIND ( ">", 'Table'[Operator],, BLANK () ) <> BLANK (), "True",
        'Table'[Value1] = 'Table'[Value2]
            && FIND ( "=", 'Table'[Operator],, BLANK () ) <> BLANK (), "True",
        'Table'[Value1] < 'Table'[Value2]
            && FIND ( "<", 'Table'[Operator],, BLANK () ) <> BLANK (), "True",
        "False"
    )
    

     The result is as follow:

     

     

    Best Regards

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