Forum Discussion

Walt1010's avatar
Walt1010
Helper V
2 years ago
Solved

Noob Modelling Question re Select Equivalents

I have 2 tables of phone calls, one incoming calls and 1 outgoing. Both are joined to a phone directory table that contains their numbers. The joins are both many-to-one. Both tables are also linked ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Walt1010 

     

    Thank you very much amitchandak for your prompt reply.

     

    I found your question when I checked the forum, may I ask if your problem has been solved? If not, here are some ideas.

     

    Here's some dummy data

     

    “Incoming Calls”

     

    “Outgoing Calls”

     

    “Phone Directory”

     

     

    Create a new table that combines both incoming and outgoing calls.

     

    CombinedCalls = 
    UNION(
        SELECTCOLUMNS(
            'Incoming Calls',
            "PhoneNumber", 'Incoming Calls'[PhoneNumber],
            "CallType", "Incoming",
            "Duration", 'Incoming Calls'[Duration],
            "Date", 'Incoming Calls'[Date]
        ),
        SELECTCOLUMNS(
            'Outgoing Calls',
            "PhoneNumber", 'Outgoing Calls'[PhoneNumber],
            "CallType", "Outgoing",
            "Duration", 'Outgoing Calls'[Duration],
            "Date", 'Outgoing Calls'[Date]
        )
    )
    

     

    Create a column to identify phone numbers that have both incoming and outgoing calls.

     

    HasBothCalls = 
    CALCULATE(
        COUNTROWS(CombinedCalls),
        FILTER(
            VALUES(CombinedCalls[PhoneNumber]),
            COUNTROWS(
                FILTER(CombinedCalls, CombinedCalls[PhoneNumber] = EARLIER(CombinedCalls[PhoneNumber]) && CombinedCalls[CallType] = "Incoming")
            ) > 0 &&
            COUNTROWS(
                FILTER(CombinedCalls, CombinedCalls[PhoneNumber] = EARLIER(CombinedCalls[PhoneNumber]) && CombinedCalls[CallType] = "Outgoing")
            ) > 0
        )
    )
    

     

     

    Create a relationship between the Phone Directory table and the CombinedCalls table.

     

     

    Filters the record for which HasBothCalls is 1.

     

     

    And you can add a month slicer for filtering. Here is the result.

     

     

     

     

    Regards,

    Nono Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.