Forum Discussion
The sum of rows pr column
Hey,
I am new user and I wonder how to write a DAX-code to get the sum (Hours totally) of each column based on periods 202401, 202402, etc... I tried with sum and filter but it didn't work.
5 Replies
- Greg_Deckler
Community Champion
alissska24 First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e
This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376
Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8 - AnonymousNot applicable
Hi,
Thanks fot the solution Greg_Deckler provided, and i want to offer somre more information for user to refer to.
hello alissska24 , based on your descriotion, you can refer to the following solution.
Sample data
1.IF you just want to display the total, you can put the data to a matrix visual, it can display the total.
2.You can create a measure
MEASURE = CALCULATE ( SUM ( 'Table'[Planlagt] ), ALLSELECTED ( 'Table' ), 'Table'[Period] IN VALUES ( 'Table'[Period] ) )Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- alissska24New Member
Thank you! And how can I make a table at dashboard that will show this when I have data as table and as measuer? And the last row (Resources needed) suppose to be 'divide' function.
- AnonymousNot applicable
Hi alissska24
Thanks for your quick reply, you can refer to the following solution.
Sample data
1.Create a 1:N relationship between tables
2.Create the following measures
TotalHours = SUM('Table'[Planlagt])Hour per month = SUM('Table (2)'[Verdi])Resource needed = SUMX(VALUES('Table (2)'[Period]),DIVIDE([TotalHours],[Hour per month]))Then put the period field of the table(2) and the measures to the table visual.
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.