Forum Discussion
PatrickLamoste
Helper I
7 years agoI'm getting duplicated rows when table relationships are established...
Hi, I am currently working on 2 tables the first table has an employees total hours for the day and the second table is the department details of the employee. When I establish a relationship and...
- 7 years ago
hi, PatrickLamoste
Since your two table is a many to many relationship, and there is no [DEPARTMENT] filed in table1, so it will lead to this result.
And from your sample data, I think this your expected output.
Create a measure instead of drag [Hours] into visual directly.
Measure = CALCULATE ( SUM ( Table1[HOURS] ), FILTER ( Table1, Table1[ENTRY DATE] >= MIN ( Table2[EFFECTIVE DATE] ) && Table1[ENTRY DATE] <= IF ( MAX ( Table2[END DATE] ) = BLANK (), DATE ( 9999, 12, 31 ), MAX ( Table2[END DATE] ) ) ) )Result:
and here is sample pbix file, please try it.
Best Regards,
Lin
v-lili6-msft
Community Support
7 years agohi, PatrickLamoste
Since your two table is a many to many relationship, and there is no [DEPARTMENT] filed in table1, so it will lead to this result.
And from your sample data, I think this your expected output.
Create a measure instead of drag [Hours] into visual directly.
Measure =
CALCULATE (
SUM ( Table1[HOURS] ),
FILTER (
Table1,
Table1[ENTRY DATE] >= MIN ( Table2[EFFECTIVE DATE] )
&& Table1[ENTRY DATE]
<= IF (
MAX ( Table2[END DATE] ) = BLANK (),
DATE ( 9999, 12, 31 ),
MAX ( Table2[END DATE] )
)
)
)
Result:
and here is sample pbix file, please try it.
Best Regards,
Lin
- PatrickLamoste7 years ago
Helper I
Thank you! This works perfectly.