cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Johan-MTM
Helper III
Helper III

Add a column for row totals

Hi,
How do I add a column that show a total for each row?

JohanMTM_0-1696318601280.png

 

1 ACCEPTED SOLUTION

Total = SUMX(q2, q2[Antal lan lantagare under 18]+q2[Antal lan vuxna lantagare]+q2[Antal lán bibliotek]+q2[Antal lán TBK]) 

 

View solution in original post

12 REPLIES 12
ChiragGarg2512
Impactful Individual
Impactful Individual

@Johan-MTM , If the simple objective is to have a column that is the sum data in each row. For ex, the new column value for "Angereds bibliotek" is 34, then

Total = q2[Antal lan lantagare under 18]+q2[Antal lan vuxna lantagare]+q2[Antal lán bibliotek]+q2[Antal lán TBK]

should work.

 

If a measure is required,

Total = SUMX(q2, q2[Antal lan lantagare under 18]+q2[Antal lan vuxna lantagare]+q2[Antal lán bibliotek]+q2[Antal lán TBK]) 
should do the trick.
Johan-MTM
Helper III
Helper III

How would the DAX look like if I want to create a new measure?

Total = SUMX(q2, q2[Antal lan lantagare under 18]+q2[Antal lan vuxna lantagare]+q2[Antal lán bibliotek]+q2[Antal lán TBK]) 

 

Sorry @ChiragGarg2512 , I didn't see your reply before I posted my question!

I tried a new measure with your sugestion but got an error:

JohanMTM_0-1696322710246.png

 

change the table name to what you have. 

Total = SUMX(q2, q2[Antal lån låntagare under 18]+q2[Antal lån vuxna låntagare]+q2[Antal lån bibliotek]+q2[Antal lån TBK])
I'm sorry but I don't get it 🙂 The error message points to "q2", should I replace this with something?

@Johan-MTM , q2 is name of the table in my pc, replace it with the name of table in your system.

Alright, here we go 🙂 All the tables but the first one (Bibliotek) are measures so this worked fine!

Total = SUMX('public loan',[Antal lån låntagare under 18]+[Antal lån vuxna låntagare]+[Antal lån bibliotek]+[Antal lån TBK])
 
One thing tho - Its the same result if I have Public loan or Public library or any other table name as format, why is that? Does it matter?

Big thanks for your patiens!
 

@Johan-MTM , This is because the measure once created are part of the model rather than that particular table. These measures can be acessed from anywhere without the name of table being attached to it, the names can be attached but it will work either way.

 

Thank You, if this solves the issue mark it as solution so that the community can fnd the solution easily.

Thank you! NOw I understand a bit more, but I do need to have seomthing there in order fpr it to work? If I remove the table name I get "Too few arguments..." 

Total = SUMX([Antal lån låntagare under 18]+[Antal lån vuxna låntagare]+[Antal lån bibliotek]+[Antal lån TBK])

@Johan-MTM , I meant the name attached to measure, like 'table'[measure] and [measure] work the same way. The reason for "Too few argument" is that the function sumx require twoarguments, name of the table and the expression. The name of the table is not optional.

 

For more information on sumx refer to this link by microsoft:

https://learn.microsoft.com/en-us/dax/sumx-function-dax

eliasayyy
Super User
Super User

hello @Johan-MTM either try using a matrix table or create a new measure that sums up all your measures and name it total

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors