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.
lbendlin , This is how data looks like
when dinv_fk = 191 , it should match its dinv_value with id_from_source , and dinv_fk_dyei value should match with irself for dinv_fk =327 , when dinv_fk is 327 , its dinv_value should be =1
| ID_FROM_SOURCE | dinv_fk_dypr | dinv_value | dinv_fk_dyei | dinv_fk_dypr | dinv_fk_dyei | dinv_value | |
| 164987 | 191 | 164987 | 260722 | 327 | 260722 | 1 | |
| 164990 | 191 | 164990 | 260725 | 327 | 260725 | 1 | |
| 164996 | 191 | 164996 | 260770 | 327 | 260813 | 1 | |
| 164997 | 191 | 164997 | 260799 | ||||
| 164998 | 191 | 164998 | 260808 | ||||
| 164999 | 191 | 164999 | 260809 | ||||
| 165000 | 191 | 165000 | 260812 | ||||
| 165001 | 191 | 165001 | 260813 |
so overall it should give me a measure as = 3, after passing all the conditions only 3 of them has cleared all filtering conditions.
once again a big thankyou for taking your time.
- lbendlin2 years ago
Super User
According to your sample data the value is 2 for 260770 ?