Forum Discussion

MightyMicrobe's avatar
MightyMicrobe
Helper II
4 years ago

Filter Two Fact Tables

I have two fact tables that are related to a dimension table, like so:

'Campaign Clicks'  *<--1 'Customers' 1 --> * 'Inbound Calls'

 

I need to build a measure showing the average number of inbound calls per customer (total calls/total customers) for the customers who called in within 7 days of clicking on the campaign. 

 

I cannot change the direction of the relationships or create bridging tables, so everything will have to be coded in measure. I tried using TREATAS, but it does not give me the results I need. Propagating filters using TREATAS in DAX - SQLBI

 

Any tips?

6 Replies

  • MightyMicrobe , Try a measure like

     

     

    Measure =
    var _min = calculate(Min('Campaign Clicks'[Start DAte]), allexcept(Customers[Customers]))
    return
    calculate(sumx(values(Customers[Customers]) , count('Inbound Calls'[Call ID]), Filter('Inbound Calls', 'Inbound Calls'[Date] >= _min && 'Inbound Calls'[Date] <=_max)))

    • MightyMicrobe's avatar
      MightyMicrobe
      Helper II

      Sorry, this does not work. The last FILTER in the RESULT clause trips it up. 

       

       

  • v-jingzhang's avatar
    v-jingzhang
    Community Support

    Hi MightyMicrobe 

     

    Can you provide some dummy data about the three tables as well as the expected result? You want to count the customers who called in within 7 days of clicking on the campaign, do they only click on the campaign once? How many campaigns are included in 'Campaign Clicks' table? Sample data will help us understand more about what you want. 

     

    Best Regards,
    Community Support Team _ Jing

    • MightyMicrobe's avatar
      MightyMicrobe
      Helper II

      Hi v-jingzhang thanks for picking this up. 

      Below is the screenshot of the model part in question, the three tables are linked on Customer ID, but there is no relationship between the two fact tables. 

      One customer can click on an unlimited number of campaigns, but for simplicity sake, I'm working with just the latest episode of clicks/calls, so something like MAXX will do. 

      • v-jingzhang's avatar
        v-jingzhang
        Community Support

        Hi MightyMicrobe 

         

        It's still not very clear. Can I consider that in 'Campaign Clicks' table, we need to get the latest time of a click for each customer. If a customer made a call/calls after that time, we need to extract the earliest call time and calculate whether the duration between "latest click time" and "earliest call time" is less than 7 days? If it is less than 7 days, then we count this customer and count how many calls he made from 'Inbound Calls' table?

         

        If my above understanding is correct, is it possible that a customer would click campaigns again after he had made a call? If so, only getting the latest click time is not appropriate as it would miss calls happened earlier than that. 

         

        Can you provide some sample data to help me understand the problem better?

         

        Best Regards,

        Jing