Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply

Return Value from Tbl2 where Tbl1.Value is between two Tbl2.Values

Hi

 

I have two tables T1 & T2

 

T1 has

CustomerIDMonthIDIndicator from T2
123452023010
234562023011
345672023010 (Returns 0 as 202301 is NOT between the start and end date in T2

 

The Indicator From T2 should return when the T1.MonthID is between the start and end months in T2

 

T2:

CustomerIDStartMonthEndMonthIndicator
123452023012023020
123452023022023040
123452023032023050
234562023012023021
345672023022023041

 

Tried various thing and either get #ERROR or no values returned

 

Any advice on best approach please?

Thanks in advance

P

1 ACCEPTED SOLUTION

@PBI_Inquisitor 
The use

Indicator from T2 = 
VAR CurrentCusomer = T1[CustomerID]
VAR CurrentMonth = T1[MonthID]
VAR T2Start = CALCULATE ( MAX ( T2[StartMonth] ), T2[CustomerID] = CurrentCusomer )
VAR T2End = CALCULATE ( MAX ( T2[EndMonth] ), T2[CustomerID] = CurrentCusomer )
RETURN
    IF ( CurrentMonth >= T2Start && CurrentMonth <= T2End, 1, 0 )

1.png

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @PBI_Inquisitor 

I assume you can build one to one relationship between the two tables. Then you can create a new calculated column in T1

Indicator from T2 =
IF (
T1[MonthID] >= RELATED ( T2[StartMonth] )

&& T1[MonthID] <= RELATED ( T2[EndMonth] ),

1,

0

)

Thanks for your reply @tamerj1 but unfortunately I cant build a 1:1 relationship in this instance - I've updated the Table 2 to show this

@PBI_Inquisitor 
The use

Indicator from T2 = 
VAR CurrentCusomer = T1[CustomerID]
VAR CurrentMonth = T1[MonthID]
VAR T2Start = CALCULATE ( MAX ( T2[StartMonth] ), T2[CustomerID] = CurrentCusomer )
VAR T2End = CALCULATE ( MAX ( T2[EndMonth] ), T2[CustomerID] = CurrentCusomer )
RETURN
    IF ( CurrentMonth >= T2Start && CurrentMonth <= T2End, 1, 0 )

1.png

Thank you so much for your help @tamerj1 - much appreciated

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.