The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
How can I convert the table on the left (italic) to the one on the right (bold) using DAX only ?
Entry | Doc No | Amount | Account | Doc No | Amount | Account | Amount Z | Account 2 | |
1 | X | 14 | A | X | 14 | A | 53 | Z | |
2 | X | 53 | Z | Y | 188 | A | 8 | Z | |
3 | Y | 67 | A | R | 88 | A | 54 | Z | |
4 | R | 17 | A | ||||||
5 | R | 71 | A | ||||||
6 | R | 54 | Z | ||||||
7 | Y | 99 | A | ||||||
8 | Y | 22 | A | ||||||
9 | Y | 4 | Z | ||||||
10 | Y | 4 | Z |
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 )
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
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsUser | Count |
---|---|
77 | |
76 | |
36 | |
31 | |
29 |
User | Count |
---|---|
93 | |
79 | |
57 | |
48 | |
48 |