Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

DAX Joining 2 tables in SWITCH statement

 Hi Below is my SWITCH in DAX which is working perfectly . Now I want to add a new condition by joining on another table. the join relation already exists in the model. basically join on table cal...
  • PhilipTreacy's avatar
    5 years ago

    Hi Anonymous 

    Please @ mention me in replies or I'll miss your response.  Type @ then select my name.

     

    Download sample PBIX with the following code and data

     

     

    No it won't but I've amended the code to this which does work.  RELATED needs a row context to work so I'm using LOOKUPVALUE on the related Development table.

    record_type_report = 
    
    VAR __Flag = LOOKUPVALUE('Development'[Flag], 'Development'[Value], SELECTEDVALUE('Table'[Value]))
    
    RETURN
    
    SWITCH( 
        
        TRUE(), 
            
        [Recordtypename__c] = "Places Development OS" && __Flag = FALSE ,"Open Market",
    
        [Recordtypename__c] = "Places Development SO" && __Flag = FALSE ,"Shared Ownership",
    
        [Recordtypename__c] = "Places Development SE" && __Flag = FALSE ,"Shared Equity",
    
        __Flag = TRUE, "NHT",
    
        [Recordtypename__c] 
    
    )

     

    Which gives this

     

    Is that the result you were looking for when 'Development'[Flag] = True to give NHT ?

    Regards

    Phil