Forum Discussion
Anonymous
6 years agoNot applicable
Power BI Date Range Lookup
I have below two tables. I need to lookup on my date range table and fetch the Interest rate if the business date lies between the from date and to date. The expected output looks like below....
- 6 years ago
Generally I do something like:
Interest Rate Column = VAR __Date = 'Table1'[Business Date] VAR __ID = 'Table1'[Loan ID] VAR __Rate = MAXX( FILTER( ALL('Table2'), 'Table2'[Loan ID] = __ID && 'Table2'[From Date] <= __Date && 'Table2'[To Date] >= __Date ), [Interest Rate] ) RETURN __Rate
az38
6 years agoCommunity Champion
Hi Anonymous
try
test_roi = CALCULATE(
FIRSTNONBLANK((test_lms_loan_roi[eff_rate]), 1),
FILTER(ALL(test_lms_loan_roi),
SELECTEDVALUE(lms_dailybalance_cashflow[Business Date]) >= test_lms_loan_roi[eff_fromdate] && SELECTEDVALUE(lms_dailybalance_cashflow[Business Date]) <= test_lms_loan_roi[eff_todate] && test_lms_loan_roi[mg_intcomp] = 158)
)
Anonymous
6 years agoNot applicable
Hi az38 , above formula is giving all blank values.
- az386 years agoCommunity Champion
Anonymous
what is 158? in what table do you create the measure?
- Anonymous6 years agoNot applicable
az38 I am creating calculated column in my Input table where Business Date and Loan ID is there.
158 is code for specific type of Interest. It is part of business logic that needs to be applied. But when I removed 158 condition from your formula, it does give some value but a wrong one 😞
- az386 years agoCommunity Champion
So Anonymous
this 158 is defined in both of tables?