Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Super User
Super User

@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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.