Forum Discussion

twowaysyellow's avatar
twowaysyellow
Frequent Visitor
2 years ago
Solved

Creating an intermediate table from two existing tables

I want to create an intermediate table based on the relationship between two existing tables.   I have two existing tables; Tickets and Events.   Table: Tickets ticket_id guest_id event_id ...
  • parry2k's avatar
    2 years ago

    twowaysyellow add following expression to create the table

     

    Table = 
    VAR __Table = 
    SELECTCOLUMNS ( Tickets, "Ticket_Id", Tickets[ticket_id],  "User_Id", Tickets[guest_id], "Event_Id", Tickets[event_id], "Host_Id", RELATED ( Events[host_id] ) )
    RETURN
    UNION (
        ADDCOLUMNS ( 
            SELECTCOLUMNS (
                __Table,
                [Ticket_Id], [User_Id], [Event_ID]
            ), "Guest_Id", "Guest" 
        ),
        ADDCOLUMNS ( 
            SELECTCOLUMNS (
                __Table,
                [Ticket_Id], [Host_Id], [Event_ID]
            ), "Guest_Id", "Host" 
        )
    )