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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NotVeryGoodatBI
Frequent Visitor

Need Help With LOOKUPVALUE or need ideas

Hello, I am a little new to PowerBI and I am trying find a function like Excel's VLOOKUP that will allow me to create a column in Invoice Table 1 that pulls correct margin value from the time frame of the invoice instance. I need a function not a join please!

 

Table 1: Invoice_Table

invoice_numberIDstart_date   end_date Created_Field_Margin(Margin_Table)
5456110/20/202311/20/2023 
511521/19/20242/19/2024 
1515633/25/20244/26/2024 
515541/18/20242/22/2024 
46565511/20/202312/10/2024 

 

Table 2: Margin_Table

IDstart_dateend_dateMargin
110/20/20231/10/20240.32
210/21/20231/11/20240.55
310/22/20231/12/20240.11
410/23/20231/13/20240.55
510/30/20231/14/20240.57
11/11/20245/21/20240.35
21/12/20245/22/20240.62
31/13/20245/23/20240.16
41/14/20245/24/20240.54
51/15/20245/25/20240.58

 

Desired Output:

This created Margin field would pull the Margin value from the Margin_Table based on the 'ID' and where the invoice falls within start_date and end_date

invoice_numberIDstart_dateend_datecreated_field_margin(Margin_Table)
5456110/20/202311/20/20230.32
511521/19/20242/19/20240.62
1515633/25/20244/26/20240.16
515541/18/20242/22/20240.54
46565511/20/202312/10/20240.57
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @NotVeryGoodatBI ,

Please try the following methods and check if they can solve your problem:

1.Create a new column. Enter the following DAX formula.

Margin_table(Margin) = 
CALCULATE(SUM('Margin_Table'[Margin]),
FILTER('Margin_Table',
'Margin_Table'[ID]='Invoice_Table'[ID]&&'Margin_Table'[start_date]<='Invoice_Table'[start_date]&&'Margin_Table'[end_date]>='Invoice_Table'[start_date]))

 

2.Drag the new column to the Invoice_Table.

vjiewumsft_0-1706601925106.png

3.The result is shown below.

vjiewumsft_1-1706601986683.png

 

Best Regards,

Wisdom Wu

 

 

 

 

 

 

View solution in original post

5 REPLIES 5
NotVeryGoodatBI
Frequent Visitor

Hello, if anyone could help me with the formula to create a column in Invoice Table 1 that pulls correct margin value from Margin Table 2 based on the ID and time frame of the invoice instance. I need a function not a join please!

 

Table 1: Invoice_Table

IDstart_dateend_dateMargin
110/20/20231/10/20240.32
210/21/20231/11/20240.55
310/22/20231/12/20240.11
410/23/20231/13/20240.55
510/30/20231/14/20240.57
11/11/20245/21/20240.35
21/12/20245/22/20240.62
31/13/20245/23/20240.16
41/14/20245/24/20240.54
51/15/20245/25/20240.58

 

Table 2: Margin_Table

invoice_numberIDstart_dateend_dateMargin_table(Margin)
5456110/20/202311/20/2023 
511521/19/20242/19/2024 
1515633/25/20244/26/2024 
515541/18/20242/22/2024 
46565511/20/202312/10/2024 

 

Desired Output:

This created Margin field would pull the Margin value from the Margin_Table based on the 'ID' and where the invoice falls within start_date and end_date:

invoice_numberIDstart_dateend_dateMargin_table(Margin)
5456110/20/202311/20/20230.32
511521/19/20242/19/20240.62
1515633/25/20244/26/20240.16
515541/18/20242/22/20240.54
46565511/20/202312/10/20240.57
Anonymous
Not applicable

Hi @NotVeryGoodatBI ,

If I understand correctly, the issue is that you want to find a function to create a column. Please try the following methods and check if they can solve your problem:

1.Create a new column. Enter the following DAX formula.

 

Column = LOOKUPVALUE(Margin_Table[Margin], Margin_Table[ID], Invoice_Table[ID], Margin_Table[start_date], Invoice_Table[start_date])

 

 

2.Drag the column into the table visual.

vjiewumsft_0-1706506224035.png

3.The result is shown below.

vjiewumsft_1-1706506271621.png

4.You can also use the following link to learn the function.

LOOKUPVALUE function (DAX) - DAX | Microsoft Learn

 

If the above ones can’t help you get it working, could you please provide the desired result screenshot to make a deep troubleshooting? It would be helpful to find out the solution.

 

Best Regards,

Wisdom Wu

 

 

 

 

 

 

Hello v-jiewu-msft, 

Thank you for your comment. The desired output is below. I need a calculated column function that will match the ID from Invoice_Table1 to the ID in Margin_Table2, as well as filter MarginTable2 for the time frame listed in Invoice_Table1, grabbing the margin each row by matching the ID and timeframe.

invoice_numberIDstart_dateend_dateMargin_table(Margin)
5456110/20/202311/20/20230.32
511521/19/20242/19/20240.62
1515633/25/20244/26/20240.16
515541/18/20242/22/20240.54
46565511/20/202312/10/20240.57
PREVIEW
 
 
 
Anonymous
Not applicable

Hi @NotVeryGoodatBI ,

Please try the following methods and check if they can solve your problem:

1.Create a new column. Enter the following DAX formula.

Margin_table(Margin) = 
CALCULATE(SUM('Margin_Table'[Margin]),
FILTER('Margin_Table',
'Margin_Table'[ID]='Invoice_Table'[ID]&&'Margin_Table'[start_date]<='Invoice_Table'[start_date]&&'Margin_Table'[end_date]>='Invoice_Table'[start_date]))

 

2.Drag the new column to the Invoice_Table.

vjiewumsft_0-1706601925106.png

3.The result is shown below.

vjiewumsft_1-1706601986683.png

 

Best Regards,

Wisdom Wu

 

 

 

 

 

 

lbendlin
Super User
Super User

Why would an invoice have a start and end date?  What should happen if the invoice time interval spans two or more margin intervals ?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.