Forum Discussion
Count rows with different tables
- 4 years ago
Hi DjZijlstra ,
This is because I did not de-duplicate the TbIContract[MainUnitID] column, please try the modified measure:
count the units with contract = VAR tab_contract = FILTER ( TbIContract, AND ( TbIContract[DateContractFrom] <= MAX ( 'dates'[date] ), OR ( TbIContract[DateContractTo] >= MAX ( 'dates'[date] ), TbIContract[DateContractTo] = 0 ) ) ) VAR tab_units = FILTER ( TbIUnits, AND ( TbIUnits[ExploitationDateForm] <= MAX ( dates[date] ), OR ( TbIUnits[ExploitationDateTo] >= MAX ( dates[date] ), TbIUnits[ExploitationDateTo] = 0 ) ) ) RETURN CALCULATE ( DISTINCTCOUNT(TbIContract[MainUnitID]), tab_contract, tab_units, USERELATIONSHIP ( TbIUnits[UnitID], TbIContract[MainUnitID] ) )If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi DjZijlstra ,
This is because I did not de-duplicate the TbIContract[MainUnitID] column, please try the modified measure:
count the units with contract =
VAR tab_contract =
FILTER (
TbIContract,
AND (
TbIContract[DateContractFrom] <= MAX ( 'dates'[date] ),
OR (
TbIContract[DateContractTo] >= MAX ( 'dates'[date] ),
TbIContract[DateContractTo] = 0
)
)
)
VAR tab_units =
FILTER (
TbIUnits,
AND (
TbIUnits[ExploitationDateForm] <= MAX ( dates[date] ),
OR (
TbIUnits[ExploitationDateTo] >= MAX ( dates[date] ),
TbIUnits[ExploitationDateTo] = 0
)
)
)
RETURN
CALCULATE (
DISTINCTCOUNT(TbIContract[MainUnitID]),
tab_contract,
tab_units,
USERELATIONSHIP ( TbIUnits[UnitID], TbIContract[MainUnitID] )
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks v-kkf-msft .
Thats what i'm looking for.