Forum Discussion
GMkk
Helper I
2 years agoconvert 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...
- Anonymous2 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 XuIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
GMkk
Helper I
2 years agoso our firstcondition (LEFT OUTER JOIN B AS customIncident ON customIncident.dinv_fk_dypr = 191 and customIncident.dinv_value = A.ID_FROM_SOURCE) looks like
| ID_FROM_SOURCE(Table-A) | dinv_fk_dypr(Table-B) | dinv_value (Table-B) | dinv_fk_dyei (Table-B) |
| 164987 | 191 | 164987 | 260722 |
| 164988 | |||
| 164989 | |||
| 164990 | 191 | 164990 | 260725 |
| 164992 | |||
| 164993 | |||
| 164994 | |||
| 164995 | |||
| 164996 | 191 | 164996 | 260770 |
| 164997 | 191 | 164997 | 260799 |
| 164998 | 191 | 164998 | 260808 |
| 164999 | 191 | 164999 | 260809 |
| 165000 | 191 | 165000 | 260812 |
| 165001 | 191 | 165001 | 260813 |
| 165003 | 191 | 165003 | 260831 |
| 165002 | 191 | 165002 | 260826 |