Forum Discussion
awitt
Helper III
4 years agoISBETWEEN with Many to Many Relationship
Hello everyone,
I'm looking to add a column that returns a 0 or 1 for if a certain record in the table has a date that falls inbetween a date range from another table.
For example this data, which the pbix file is attached, would generate a "1" for Index #s 0, 1 , 7 , 9 , 10 , 12 and 16 since they fall within one of the windows for their relative SchoolID.
You could do this with a calculated column like the following:
= COUNTROWS(filter( SemesterTable,
SemesterTable[SchoolID] = ShippingTable[SchoolID]
&& SemesterTable[WeekBeforeStart] <= ShippingTable[ShipDate]
&& SemesterTable[WeekAfterStart].[Date] >= ShippingTable[ShipDate])
)+ 0
2 Replies
- d_gosbell
Super User
You could do this with a calculated column like the following:
= COUNTROWS(filter( SemesterTable,
SemesterTable[SchoolID] = ShippingTable[SchoolID]
&& SemesterTable[WeekBeforeStart] <= ShippingTable[ShipDate]
&& SemesterTable[WeekAfterStart].[Date] >= ShippingTable[ShipDate])
)+ 0 - Ashish_Mathur
Super User
Hi,
This calculated column formula works
Column = CALCULATE(COUNTROWS(SemesterTable),FILTER(SemesterTable,SemesterTable[WeekBeforeStart]<=EARLIER(ShippingTable[ShipDate])&&SemesterTable[WeekAfterStart]>=EARLIER(ShippingTable[ShipDate])&&SemesterTable[SchoolID]=EARLIER(ShippingTable[SchoolID])))Hope this helps.