March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi All,
I'm trying to lookup some information from Table 1 below to Table 2.
Table 1 - Sales info:
Customer | Product | Sales | Contract Start Date | Contract End Date | Fiscal Year of Order Date |
A | Z | 100 | 1/1/2018 | 12/31/2018 | 2018 |
A | Y | 200 | 1/1/2018 | 12/31/2018 | 2018 |
A | Z | 200 | 4/1/2018 | 12/31/2018 | 2018 |
B | Y | 400 | 9/1/2018 | 4/1/2019 | 2018 |
B | Y | 300 | 1/1/2019 | 9/30/2020 | 2019 |
A | Z | 150 | 10/1/2019 | 4/1/2020 | 2019 |
Table2 - Issues Info:
Customer | Product | Total No. of Issues | Issue Date |
A | Z | 2 | 1/1/2018 |
A | Y | 5 | 1/1/2018 |
A | Z | 3 | 5/4/2018 |
B | Y | 7 | 12/30/2018 |
B | Y | 3 | 8/1/2020 |
A | Z | 2 | 11/23/2019 |
Ultimately, we would like to have Table 2 looks like below with additional column lookup-ed from Table 1 (Fiscal Year of Order Date):
Customer | Product | Total No. of Issues | Issue Date | Fiscal Year of Issue Date |
A | Z | 2 | 1/1/2018 | 2018 |
A | Y | 5 | 1/1/2018 | 2018 |
A | Z | 3 | 5/4/2018 | 2018 |
B | Y | 7 | 12/30/2018 | 2018 |
B | Y | 3 | 8/1/2020 | 2019 |
A | Z | 2 | 11/23/2019 | 2019 |
'Fiscal Year of Order Date' is match in Table 2 if and only if the Issue Date falls between the 'Contract Start Date' and 'Contract End Date'.
I've tried to create additional column "Key" by concatenate "Customer" & "Product". Then I've linked them up between both tables as Many-to-many relationship.
Below are the expressions that I have tried out by using the function RELATED(),
Solved! Go to Solution.
Thank you! @Anonymous
This works well with slight modifications per below:
Column =
VAR Prod = 'Issues Info'[Product]
VAR Cust = 'Sales Info'[Customer]
VAR _issue = 'Issues Info'[Issue Date ]
VAR _result = CALCULATE(MAX('Sales Info'[Fiscal Year of Order Date ]),FILTER('Sales Info','Sales Info'[Contract Start Date ]<=_issue && 'Sales Info'[Contract End Date ]>=_issue && 'Sales Info'[Product] = Prod &&'Sales Info'[Customer]= Cust))
RETURN _result
@JOO13 Create this calculated column in Issue Info table
Column =
VAR _issue = 'Issues Info'[Issue Date ]
VAR _result = CALCULATE(MAX('Sales Info'[Fiscal Year of Order Date ]),FILTER('Sales Info','Sales Info'[Contract Start Date ]<=_issue && 'Sales Info'[Contract End Date ]>=_issue && 'Sales Info'[Product] = 'Issues Info'[Product ]&&'Sales Info'[Customer]='Issues Info'[Customer ]))
RETURN _result
and check if it works for you
Thank you! @Anonymous
This works well with slight modifications per below:
Column =
VAR Prod = 'Issues Info'[Product]
VAR Cust = 'Sales Info'[Customer]
VAR _issue = 'Issues Info'[Issue Date ]
VAR _result = CALCULATE(MAX('Sales Info'[Fiscal Year of Order Date ]),FILTER('Sales Info','Sales Info'[Contract Start Date ]<=_issue && 'Sales Info'[Contract End Date ]>=_issue && 'Sales Info'[Product] = Prod &&'Sales Info'[Customer]= Cust))
RETURN _result
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
133 | |
91 | |
88 | |
64 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
73 | |
68 |