Forum Discussion

GMkk's avatar
GMkk
Icon for Helper I rankHelper I
2 years ago
Solved

convert sql joins to dax

hi everyone, this is my sql  SELECT COUNT(inc_incident_DW.inc_incident_ref) AS Inc_No --,luynt_description --,FeedbackYN.dinv_value FROM inc_incident_DW LEFT OUTER JOIN sta_station_DW ON inc_in...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi GMkk 

     

    lbendlin , thanks for your concern about this case.

     

    The following formula is for your reference:

     

    Measure = 
    VAR _tab1 = CALCULATETABLE(VALUES('Table-B'[dinv_fk_dyei]), FILTER(ALLSELECTED('Table-B'), 'Table-B'[dinv_fk_dypr] = 191 && 'Table-B'[dinv_value] in VALUES('Table-A'[ID_FROM_SOURCE])))
    var _tab2 = CALCULATETABLE(VALUES('Table-B'[dinv_fk_dyei]), FILTER(ALLSELECTED('Table-B'), 'Table-B'[dinv_fk_dypr] = 327 && 'Table-B'[dinv_value] = 1 && 'Table-B'[dinv_fk_dyei] in _tab1))
    return COUNTROWS(_tab2)

     

     

    But I have a small doubt to confirm with you, I tested it in the database with the SQL statement you provided and the count is 7. If I have misunderstood you, could you please explain further? Thank you in advance for your time.

     

    Result:

     

    Best Regards,
    Yulia Xu

     

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