Forum Discussion

Nepal101's avatar
Nepal101
Icon for Helper III rankHelper III
2 years ago
Solved

Working with Many to Many doesn't give me correct value.

Hello Everyone,  I was trying to create a table by merging two different tables in one but I am getting duplicate rows for dates. I tried to create a bridge table instead of merging the two tables t...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Nepal101 ,

     

    Thanks Ritaf1983  for the quick reply. I have some additional suggestions:

    (1)Add a column to Table 1.

    rank = RANKX(FILTER('Table (1)',[Client name ]=EARLIER('Table (1)'[Client name ]) ),[Communicationdate ],,ASC,Dense)

    (2)Add a column to Table 2.

    rank = RANKX(FILTER('Table (2)',[client name ]=EARLIER('Table (2)'[client name ])),[Sample provided date],,ASC,Dense)

    (3)We can create a table.

    NewTable =
    SELECTCOLUMNS (
        ADDCOLUMNS (
            'Table (1)',
            "s_date",
                CALCULATE (
                    MAX ( 'Table (2)'[Sample provided date] ),
                    FILTER (
                        'Table (2)',
                        [Client name ] = EARLIER ( 'Table (1)'[Client name ] )
                            && [code] = EARLIER ( 'Table (1)'[code] )
                            && [rank] = EARLIER ( 'Table (1)'[rank] )
                    )
                )
        ),
        "Client name", [Client name ],
        "Communicationdate", [Communicationdate ],
        "Sample Provided date", [s_date]
    )
    

     

    Best Regards,

    Neeko Tang

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