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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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