Forum Discussion

StephenClarke's avatar
StephenClarke
Frequent Visitor
3 years ago
Solved

Range Lookup for Marketing Attribution

Dear Community Forum,   I would like to run a formula that assigns a last touch attribtion logic of marketing activity to my orders.   I have: an Order table showing which cleints ordered when ...
  • DataInsights's avatar
    3 years ago

    StephenClarke,

     

    Try this calculated column in the Orders table. There is no relationship between these tables in this example.

     

    Marketing Activity = 
    VAR vTransactionDate = Orders[Transaction Date]
    VAR vClient = Orders[Client]
    VAR vMarketingTable =
        FILTER (
            Marketing,
            Marketing[Client] = vClient
                && Marketing[Date of Marketing Activity] < vTransactionDate
                && Marketing[Date of Marketing Activity] >= vTransactionDate - 90
        )
    VAR vMaxDateMarketingActivity =
        MAXX ( vMarketingTable, Marketing[Date of Marketing Activity] )
    VAR vResult =
        MAXX (
            FILTER (
                vMarketingTable,
                Marketing[Date of Marketing Activity] = vMaxDateMarketingActivity
            ),
            Marketing[Marketing Activity]
        )
    RETURN
        IF ( ISBLANK ( vResult ), "NA", vResult )