Forum Discussion
groupby
Hi vjnvinod,
Use this formula to create your new DAX Table:
NewColumn =
GROUPBY (
Inbound;
Inbound[AccountSector];
"TERFYTD USD"; SUMX ( CURRENTGROUP (); Inbound[TER_FYTD_USD] )
)
Regards.
- TomMartens8 years agoSuper User
Hey,
as Anonymous already presented a correct answer using GROUPBY(), I just want to add some additional information about this function https://www.sqlbi.com/articles/nested-grouping-using-groupby-vs-summarize/ and here the official documentation https://msdn.microsoft.com/en-us/query-bi/dax/groupby-function-dax
But if you do not need GROUPBY you should consider to use SUMMARIZECOLUMNS() instead https://msdn.microsoft.com/en-us/query-bi/dax/summarizecolumns-function-dax) or still SUMMARIZE, because it's much more performant.
The DAX statement using SUMMARIZECOLUMNS:
Table using SUMMARIZECOLUMNS = SUMMARIZECOLUMNS( 'Inbound'[Account Sector],"new column", SUM('Inbound'[TERFYTD USD]) )The perfomance aspect is described in a new DAX book that you will find here: https://www.amazon.com/Beginning-DAX-Power-BI-Intelligence/dp/1484234766/ref=sr_1_1?ie=UTF8&qid=1526070538&sr=8-1&keywords=beginning+dax+with+power+bi by me fellow datanaut Phil_Seamark
Here is the DAX statement using ADDCOLUMNS(SUMMARIZE(...
Table using ADDCOLUMN SUMMARIZE = ADDCOLUMNS( SUMMARIZE( 'Inbound' ,'Inbound'[Account Sector] ) ,"Wrong Result", SUM('Inbound'[TERFYTD USD]) ,"Correct Result", CALCULATE(SUM('Inbound'[TERFYTD USD])) )There is also a great article on sqlbi.com coparing SUMMARIZE and SUMMARIZECOLUMNS: https://www.sqlbi.com/articles/introducing-summarizecolumns/
Hope this gets you started
Regards
Tom
- vjnvinod8 years agoImpactful Individual
This is really helpful, thanks for sharing this information.
Despite creating this new table and relationship, my data doesn't interacts with each other, not sure why.
- TomMartens8 years agoSuper User
Hey,
wondering what you mean by "doesn't" interact.
I guess this means that there is more than table involved and/or there are slicers.
From your post I deduct that you try to "relate" the tables, your original one and the one created by one of the DAX statements. This won't work, due to the design of the Power BI Model.
Ideally you create a pbix with sample data that helps to recreate your issue, upload this pbix file to onedrive or dropbox and share the link.
And it would also be helpful to describe in more detail what doesn't work.
Regards
Tom