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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Jabe2015
New Member

User Variable from Table to specify column lookup

Hi All, 

 

DAX newb here. Spent the better part of the day searching for an answer to this. 

 

Desired Result:

To create a column in table 1 sourced from table 2 where: 

1. product number matches

2. order date falls inside of the effective dates

3. the correct rate pulled from the correct client column. 

 

As you may realize there are different rates based on client, product and effective dates. 

 

Table 1: Client Orders
Order DateProduct NumberClientNew Column
Client Rate
2/10/20211871Client 1750
2/10/20211871Client 2625
2/10/20211871Client 3500
5/6/20224580Client 12500
5/7/20224580Client 22375
5/8/20224580Client 32250

 

Table 2: Client Rates
Effective StartEffective EndProduct NumberClient 1Client 2Client 3
1/1/202212/31/20224580250023752250
1/1/202112/31/20214580750625500
1/1/202212/31/20221871250023752250
1/1/202112/31/20211871750625500
1/1/202212/31/20221870250023752250

 

Many thanks in advance for assistance. 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Jabe2015 , You have to create a column like

 

maxx(filter(Table2, Table2[Product Number] =Table1[Product Number] && Table1[Order Date] >= Table2[Effective Start] && Table1[Order Date] <= Table2[Effective End] ), Table2[Client1])

 

or

 

 

maxx(filter(Table2, Table2[Product Number] =Table1[Product Number] && Table1[Order Date] >= Table2[Effective Start] && Table1[Order Date] <= Table2[Effective End] ), calculate(Maxx({Table2,[Client1],[Client2], [Client3]} , [Value])) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Jabe2015 , You have to create a column like

 

maxx(filter(Table2, Table2[Product Number] =Table1[Product Number] && Table1[Order Date] >= Table2[Effective Start] && Table1[Order Date] <= Table2[Effective End] ), Table2[Client1])

 

or

 

 

maxx(filter(Table2, Table2[Product Number] =Table1[Product Number] && Table1[Order Date] >= Table2[Effective Start] && Table1[Order Date] <= Table2[Effective End] ), calculate(Maxx({Table2,[Client1],[Client2], [Client3]} , [Value])) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you @amitchandak for the prompt response. How would I use client id variable derived from Table 1 to select the correct client column in table 2 to look up the rate? Reason is, new clients will be added frequently, and would like to reduce the need to update code each client. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors