Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Do value search between two tables

Hello, 

I have two tables and in one of them I would like to create a column "IS" column which returns the value of "ServiceB" if "nameA" exists in "nameB" otherwise it returns the value "T". Can you please help me do this? 

TABLE A :

DateNomAServiceA
2021-09totoyes
2021-09dreamno
2021-09firehurry

 

TABLE B :

DateNomBServiceB
2021-09iceyes
2021-09dreamno
  • Anonymous  as calculated column

     

    calculatedColumnWithTREATAS = 
    VAR _a =
        CALCULATE (
            CALCULATE (
                MAXX ( t2, 't2'[ServiceB] ),
                TREATAS ( VALUES ( t1[NomA] ), t2[NomB] )
            )
        )
    RETURN
        IF ( ISBLANK ( _a ), "T", _a )

     

     

     

     

    as measure

    measureWithTREATAS = 
    VAR _a =
        CALCULATE (
            MAXX ( t2, 't2'[ServiceB] ),
            TREATAS ( VALUES ( t1[NomA] ), t2[NomB] )
        )
    RETURN
        IF ( ISBLANK ( _a ), "T", _a )

     

     

     

     

     

5 Replies

  • jppv20's avatar
    jppv20
    Icon for Solution Sage rankSolution Sage

    Hi Anonymous ,

     

    Try this:

     

    IS 2 = IF(LOOKUPVALUE('Table B'[ServiceB],'Table B'[NomB],'Table A'[NomA])<>BLANK(),LOOKUPVALUE('Table B'[ServiceB],'Table B'[NomB],'Table A'[NomA]),"T")
     
    If I answered your question, please mark it as a solution to help other members find it more quickly.
    • Anonymous's avatar
      Anonymous
      Not applicable

      Why are you using the blank() function?

  • Hi Anonymous 

     

    Try this:

    IS = 
    Var _A = LOOKUPVALUE('TABLE B'[ServiceB],'TABLE B'[NomB],'TABLE A'[NomA])
    return
    if(ISBLANK(_A),"T",_A)

     

    output:

     

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/

     

     

  • smpa01's avatar
    smpa01
    Icon for Community Champion rankCommunity Champion

    Anonymous  as calculated column

     

    calculatedColumnWithTREATAS = 
    VAR _a =
        CALCULATE (
            CALCULATE (
                MAXX ( t2, 't2'[ServiceB] ),
                TREATAS ( VALUES ( t1[NomA] ), t2[NomB] )
            )
        )
    RETURN
        IF ( ISBLANK ( _a ), "T", _a )

     

     

     

     

    as measure

    measureWithTREATAS = 
    VAR _a =
        CALCULATE (
            MAXX ( t2, 't2'[ServiceB] ),
            TREATAS ( VALUES ( t1[NomA] ), t2[NomB] )
        )
    RETURN
        IF ( ISBLANK ( _a ), "T", _a )