Forum Discussion
Summing values in a row
Hi,
Need your help again and again please,
I have the following case:
P1 P2 P3 P4
1 4 3 4
2 6 3 1
3 7 1 1
How can I create a new table to have the following
P1 P2 P3 P4
Sum(P1) Sum (P2) Sum (P3) Sum (P4)
Thanks,
Moh
Hey,
as always there is more than 1 way to achieve what you want, for this reason I created a little Power BI file
This file contains 3 tables
Table1 - sample data, created using the function "Enter Data"
UsingPowerQuery - a table created by using the Function "Group By" from the Ribbon "Transform"
UsingDAX - This table is created by the following DAX statement
UsingDAX = SUMMARIZE('Table1', "P1sum", SUM('Table1'[P1]),"P2sum", SUM('Table1'[P2]), "P3sum", SUM('Table1'[P3]),"P4sum", SUM('Table1'[P4]))Without knowing the exact use case for this requirement, my recommendation will be to go with the PowerQuery exmple.
From my point of view, tables created using Power Query can be used as persistet tables in the Data Model of Power BI, whereas tables created using DAX statements are in a way static, so the content of these tables are not controlled by the selection of slicers.
Hope this gets you started
Regards
2 Replies
- TomMartensSuper User
Hey,
as always there is more than 1 way to achieve what you want, for this reason I created a little Power BI file
This file contains 3 tables
Table1 - sample data, created using the function "Enter Data"
UsingPowerQuery - a table created by using the Function "Group By" from the Ribbon "Transform"
UsingDAX - This table is created by the following DAX statement
UsingDAX = SUMMARIZE('Table1', "P1sum", SUM('Table1'[P1]),"P2sum", SUM('Table1'[P2]), "P3sum", SUM('Table1'[P3]),"P4sum", SUM('Table1'[P4]))Without knowing the exact use case for this requirement, my recommendation will be to go with the PowerQuery exmple.
From my point of view, tables created using Power Query can be used as persistet tables in the Data Model of Power BI, whereas tables created using DAX statements are in a way static, so the content of these tables are not controlled by the selection of slicers.
Hope this gets you started
Regards
- v-huizhn-msftMicrosoft Employee
Hi abukapsoun,
As I tested, the solution TomMartens posted is right. If you have resolved your issue, please mark the right reply as answer.
Thanks,
Angelia