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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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