Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

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.

  • 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])

     

     

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

    Best Regards,
    Angelia

1 Reply

  • v-huizhn-msft's avatar
    v-huizhn-msft
    Microsoft 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])

     

     

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

    Best Regards,
    Angelia