Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

DAX generated table with related data

Hello all,   I have a powerbi report containing a table that looks like : Product ID Transaction ID Qty A X 1 B X 2 C X 1 A Y 2 B Y 1 A Z 1 C Z 1   ...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous 

    You need to duplicate a same table like original one, and change all the column names in new table. Because Power BI doesn't support two columns have the same name. Then you can build a dax code as below to build the table you want.

     

    New Table =
    VAR _T =
        CROSSJOIN ( 'Table', 'Ass Table' )
    VAR _T2 =
        SUMMARIZE (
            FILTER (
                _T,
                [Product ID] <> [Ass Product ID]
                    && [Transaction ID] = [Ass Transaction ID]
            ),
            [Product ID],
            [Ass Product ID],
            "QTY", SUM ( 'Table'[Qty] ),
            "Count of Transactions", COUNT ( 'Table'[Transaction ID] )
        )
    RETURN
        _T2

     

    Result is as below.

    Best Regards,

    Rico Zhou

     

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