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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ElvirBotic
Helper III
Helper III

DAX Help to get sum by week

Hello, Community, 

 

I am looking for some help on how to populate a calculated column based on a function I want to create. I added a screenshot of the result I am looking for. What I want the function to do is sum 3 coumns I have in my model and based on the week number sum by that week and insert the result of that week with the three different columns into a different column named 'Weekly Sum'

Power BI Community Help.PNG

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@ElvirBotic  Does this NEED to be a calculated column? You could use a measure:

 

SUM Measure = SUMX(Table, Table[Pass] + Table[Caution] + Table[Fail]) 

 

Then create a matrix visual with Week in Rows and SUM Measure in values.

 

Creating it as a calculated column is possible too, just need to use some filters and be aware of evaluation context, and then be careful how and where you use it, otherwise you may end up amplifying your results:

SUM Column = SUMX(FILTER(Table, Table[Week] = EARLIER(Table[Week]) , Table[Pass] + Table[Caution] + Table[Fail]) 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

3 REPLIES 3
AllisonKennedy
Super User
Super User

@ElvirBotic  Does this NEED to be a calculated column? You could use a measure:

 

SUM Measure = SUMX(Table, Table[Pass] + Table[Caution] + Table[Fail]) 

 

Then create a matrix visual with Week in Rows and SUM Measure in values.

 

Creating it as a calculated column is possible too, just need to use some filters and be aware of evaluation context, and then be careful how and where you use it, otherwise you may end up amplifying your results:

SUM Column = SUMX(FILTER(Table, Table[Week] = EARLIER(Table[Week]) , Table[Pass] + Table[Caution] + Table[Fail]) 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Does not need to be a calculated column. it was more if it is doable was my thought process. Thank you for this. What would be your recommendation for using different measures to calculate a different result to convert into a percentage? 

@ElvirBotic  If I'm understanding your question, I would do a SUM of Pass and use the DIVIDE function with the SUM Measure as denominator for a Pass Percentage as a MEASURE. Does that work?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.