Forum Discussion

gcaserta's avatar
gcaserta
Regular Visitor
4 years ago
Solved

Create a new table starting from existing data

Hi to all I have 2 tables with this structures:   Table 1 Column A: Employee  emails  Column B: Code of Primary Offices   For this table I can have for different emails the same Code of Primar...
  • v-zhangti's avatar
    v-zhangti
    4 years ago

    Hi, gcaserta 

     

    You can try the following methods.

    Column:

    Secondary Office Code 1 = 
    CALCULATE (
        MIN ( 'Table 2'[Secondary Office Code] ),
        FILTER (
            'Table 2',
            [Primary Office Code] = EARLIER ( 'Table 1'[Primary Office Code] )
        )
    )
    Secondary Office Code 2 = 
    CALCULATE (
        MIN ( 'Table 2'[Secondary Office Code] ),
        FILTER (
            'Table 2',
            [Primary Office Code] = EARLIER ( 'Table 1'[Primary Office Code] )
                && [Secondary Office Code] <> EARLIER ( 'Table 1'[Secondary Office Code 1] )
        )
    )
    Secondary Office Code 3 = 
    CALCULATE (
        MIN ( 'Table 2'[Secondary Office Code] ),
        FILTER (
            'Table 2',
            [Primary Office Code] = EARLIER ( 'Table 1'[Primary Office Code] )
                && [Secondary Office Code] <> EARLIER ( 'Table 1'[Secondary Office Code 1] )
                && [Secondary Office Code] <> EARLIER ( 'Table 1'[Secondary Office Code 2] )
        )
    )

    Table Result 1:

    New Table:

    Table Result 2 = 
    UNION (
        SUMMARIZE ( 'Table 1', [Email], 'Table 1'[Primary Office Code] ),
        SUMMARIZE ( 'Table 1', [Email], 'Table 1'[Secondary Office Code 1] ),
        SUMMARIZE ( 'Table 1', [Email], 'Table 1'[Secondary Office Code 2] ),
        SUMMARIZE ( 'Table 1', [Email], 'Table 1'[Secondary Office Code 3] )
    )

    Is this the result you expect?

     

    Best Regards,

    Community Support Team _Charlotte

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