Forum Discussion
convert sql joins to dax
- 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.
from second condition ( LEFT OUTER JOIN B AS FeedbackYN on FeedbackYN.dinv_fk_dypr = 327 and FeedbackYN.dinv_fk_dyei = customIncident.dinv_fk_dyei ) after self joining
| dinv_fk_dyei | dinv_fk_dypr | dinv_value | dinv_fk_dyei | |
| 260722 | 327 | 1 | 260722 | |
| 260725 | 327 | 1 | 260725 | |
| 260770 | 327 | 2 | 260770 | |
| 260799 | 327 | 2 | 260799 | |
| 260808 | ||||
| 260809 | ||||
| 260812 | ||||
| 260813 | 327 | 1 | 260813 | |
| 260831 | ||||
| 260826 | 327 | 1 | 260826 |
finally our mesure should count only where where FeedbackYN.dinv_value=1
so the overall measure should give me 4