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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
alissska24
New Member

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. 

 

 

Skjermbilde 2024-06-13 182453.png

alissska24_0-1718296274651.png

 

 

 

 

 

5 REPLIES 5
Anonymous
Not 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 

vxinruzhumsft_0-1718332989764.png

 

1.IF you just want to display the total, you can put the data to a matrix visual, it can display the total.

vxinruzhumsft_1-1718333035283.png

 

vxinruzhumsft_2-1718333042995.png

 

2.You can create a measure

MEASURE =
CALCULATE (
    SUM ( 'Table'[Planlagt] ),
    ALLSELECTED ( 'Table' ),
    'Table'[Period] IN VALUES ( 'Table'[Period] )
)

Output

vxinruzhumsft_3-1718333171659.png

 

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.

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. 

 

alissska24_0-1718350289733.png

alissska24_1-1718350401038.png 

alissska24_3-1718350511334.png

 

 

 

 

Anonymous
Not applicable

Hi @alissska24 

Thanks for your quick reply, you can refer to the following solution.

Sample data 

vxinruzhumsft_0-1718354151512.png

vxinruzhumsft_1-1718354174925.png

1.Create a 1:N relationship between tables

vxinruzhumsft_2-1718354234181.png

 

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.

vxinruzhumsft_3-1718354329404.png

Output

vxinruzhumsft_4-1718354427852.png

 

 

 

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.

Thanks. It worked very well. I managed to make capacity column as well, but when I add it to the diagram I get only flat line. What is missing? 

 

alissska24_0-1718375224865.pngalissska24_1-1718375274520.png

 

Greg_Deckler
Super User
Super User

@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



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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