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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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