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.
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êsCovering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
95 | |
80 | |
67 | |
62 |
User | Count |
---|---|
146 | |
110 | |
107 | |
86 | |
63 |