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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Lookup target from another table

I am unable to figure out to create a measure so that I can lookup the target for an activity based on the date range.

 

I have two tables as below. (Even though I am just showing 3 - 4 columns here, I have many and would like to use them as filters)

 

tblActivity is my fact table which contains activies, date and value. Now I want to get the targets for those activies from my DimTarget table.

 

tblActivity
ActivityDateValue
Upsell02-Jan-1710
Cross Sell11-Jan-1712
New addition25-Jan-1714
Upsell03-Feb-1716
Cross Sell20-Feb-1720
New addition27-Feb-1721

 

DimTarget
ActivityDateStartDateEndTarget
Upsell01-Jan-1731-Jan-178
Cross Sell01-Jan-1731-Jan-179
New addition01-Jan-1731-Jan-1712
Upsell01-Feb-1728-Feb-1716
Cross Sell01-Feb-1728-Feb-1718
New addition01-Feb-1728-Feb-1724

 

Desired output..

 

Output 
ActivityDateValueTarget
Upsell02-Jan-17108
Cross Sell11-Jan-17129
New addition25-Jan-171412
Upsell03-Feb-171616
Cross Sell20-Feb-172018
New addition27-Feb-172124

 

Any help would be appreciated.

1 ACCEPTED SOLUTION
v-huizhn-msft
Employee
Employee

Hi @Anonymous,

In DimTarget, the start and end time including whole month, so you can use month to identify the date. I reproduece your scenario and get expected result.

Create month column in tblActivity and DimTarget table using the formulas.

month = MONTH(tblActivity[Date])

month = MONTH(DimTarget[DateStart])


Then you can use LOOKUP function. You look up DimTarget[target] when tblActivity[Activity] equals DimTarget[Activity], and tblActivity[month] equals DimTarget[month].

target = LOOKUPVALUE(DimTarget[Target],DimTarget[Activity],tblActivity[Activity],DimTarget[month],tblActivity[month])

 

1.PNG

 

If you have other issues, don't hesitate to let me know.

Best Regards,
Angelia

View solution in original post

1 REPLY 1
v-huizhn-msft
Employee
Employee

Hi @Anonymous,

In DimTarget, the start and end time including whole month, so you can use month to identify the date. I reproduece your scenario and get expected result.

Create month column in tblActivity and DimTarget table using the formulas.

month = MONTH(tblActivity[Date])

month = MONTH(DimTarget[DateStart])


Then you can use LOOKUP function. You look up DimTarget[target] when tblActivity[Activity] equals DimTarget[Activity], and tblActivity[month] equals DimTarget[month].

target = LOOKUPVALUE(DimTarget[Target],DimTarget[Activity],tblActivity[Activity],DimTarget[month],tblActivity[month])

 

1.PNG

 

If you have other issues, don't hesitate to let me know.

Best Regards,
Angelia

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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