Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Yggdrasill
Responsive Resident
Responsive Resident

Merge a part of a table 1 with table 1 using DAX

How can I convert the table on the left (italic) to the one on the right (bold) using DAX only ?

EntryDoc NoAmountAccount Doc NoAmountAccountAmount ZAccount 2
1X14A X14A53Z
2X53Z Y188A8Z
3Y67A R88A54Z
4R17A      
5R71A      
6R54Z      
7Y99A      
8Y22A      
9Y4Z      
10Y4Z      


This is one of the things I've tried so far but with no luck

 

NewTable =
VAR _table1 =
    CALCULATETABLE (
        SUMMARIZE (
            Table,
            Table[Document No_],
            Table[Account],
            "Amount", SUM ( Table[Amount] )
        ),
        Table[G_L Account No_] = "A"
    )
VAR _table2 =
    CALCULATETABLE (
        SUMMARIZE (
            Table,
            Table[Document No_],
            Table[Account],
            "Amount", SUM ( Table[Amount] )
        ),
        Table[G_L Account No_] <> "A"
    )
RETURN
    NATURALLEFTOUTERJOIN ( _table1, _table2 )

 

1 REPLY 1
MFelix
Super User
Super User

Hello @Yggdrasill ,

Try the following code:

NewTable = 
ADDCOLUMNS(
    CALCULATETABLE (
        SUMMARIZE (
            'Table',
            'Table'[Doc No],
            'Table'[Account],
            "Amount", SUM ( 'Table'[Amount] )
        );
        'Table'[Account] = "A"
    );
    "Amount Z", CALCULATE ( SUM ( 'Table'[Amount] ), 'Table'[Account] <> "A" ),
    "Account2", CALCULATE ( VALUES ( 'Table'[Account] ), 'Table'[Account] <> "A" )
)

Note that if you have more than one value for other non-Z accounts, VALUES will return an error, so you must place a MIN or MAX value or even a hard-coded value.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.