Calculating Dynamicly Average

Automatic Mail
Automatic Mail ✭✭✭✭✭
edited 09/19/23 inFormulas and Functions

Hi there ,

İ need a formula for a dynamic calculation , i added a sample as below , lets explain what i need ;

At below table yellow field area contains August 2023 datas, white field area contains September 2023 datas , imagine that every each month , i amm adding new lines to this table also , So i have a dynamic tabe infact , i need to calculate per month'a average under the average column

how is it calculating ? I calculate total of price column all each month's and divide price with related line.

For example ;

for first line ( Material A ) average calculating = 100 / 100+200+300 = 0,17

for second line ( Material B) average calculating = 200 / 100+200+300 = 0,33

for fourth line ( Material D ) average calculating = 40 / 40+50+60 = 0,27 (above two line was belong to August Data now for this line i need to divide September's total)

etc.

every month i have many lines that i add to my sheet , i want that calculating will be related for each month and it's year , i dont want to do this calculating manually every month , is there any way to put under Average cell a formula to make this calculation automaicly ?

Thanks in advance for your kind supports .


sample.JPG


Tags:

Best Answer

  • Nick Korna
    Nick Korna ✭✭✭✭✭✭
    Answer ✓

    No problem, it's a fairly simple adjustment:

    =Price@row / SUMIF(Date:Date, AND(YEAR(@cell) = YEAR(Date@row), MONTH(@cell) = MONTH(Date@row)), Price:Price)

    Example with some data for August last year added on:

    image.png


Answers

  • Nick Korna
    Nick Korna ✭✭✭✭✭✭

    Hi@Automatic Mail,

    This formula in your Average column should do the trick:

    =Price@row / SUMIF(Date:Date, MONTH(@cell) = MONTH(Date@row), Price:Price)

    This should do what you're after, if you wanted an average by material in a given month (for example, material A was used multiple times), then you could do a SUMIFS for the Price with a similar MONTH criteria as well as the Material.

    Hope this helps, but if you've any problems/questions then just post!

  • Automatic Mail
    Automatic Mail ✭✭✭✭✭

    Dear@Nick Korna;

    Thanks for your kind reply , i forgor to say about year.The average will be related about year too , i think when i wll use your formula , if we will pass next year , there will be same months , so could you pls revise formula based on years too.every month of year must be calculated specificly i mean

  • Nick Korna
    Nick Korna ✭✭✭✭✭✭
    Answer ✓

    No problem, it's a fairly simple adjustment:

    =Price@row / SUMIF(Date:Date, AND(YEAR(@cell) = YEAR(Date@row), MONTH(@cell) = MONTH(Date@row)), Price:Price)

    Example with some data for August last year added on:

    image.png


  • Automatic Mail
    Automatic Mail ✭✭✭✭✭

    @Nick Kornayou are perfect ! this is the exactly one that i was searching , thank you very much!

  • Nick Korna
    Nick Korna ✭✭✭✭✭✭

    Glad to have helped!☺️

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the公式手册模板!
The problem is the mix of data types in the serial number column. You will need to add a helper column (can be hidden after setting up) that converts every row within that column into text and then reference this in your formula.<\/p>

=[Serial #]@row + \"//www.santa-greenland.com/community/discussion/110422/\"<\/p>

=[Column Name]@row plus quote quote<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[{"tagID":254,"urlcode":"formulas","name":"Formulas"}]},{"discussionID":110932,"type":"question","name":"I am trying to convert a formula to a column formula and keep getting the same error. Why?","excerpt":"The formula I am trying to use is calculating the number of days between 2 dates: =NETDAYS([Billing Period Start]1, [Billing Period End]1) The error message I am getting is \"The column formula syntax isn’t quite right, see our help article https:\/\/help.smartsheet.com\/articles\/2481944 for more information.\" The column type…","snippet":"The formula I am trying to use is calculating the number of days between 2 dates: =NETDAYS([Billing Period Start]1, [Billing Period End]1) The error message I am getting is \"The…","categoryID":322,"dateInserted":"2023-09-28T15:51:34+00:00","dateUpdated":null,"dateLastComment":"2023-09-28T17:29:10+00:00","insertUserID":151182,"insertUser":{"userID":151182,"name":"ajuelsgaard","url":"https:\/\/community.smartsheet.com\/profile\/ajuelsgaard","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!jD9qI_ZEy_o!ZBFrGdYxZ3o!H7BDI1juIh8","dateLastActive":"2023-09-28T17:28:44+00:00","banned":0,"punished":0,"private":false,"label":"✭✭"},"updateUserID":null,"lastUserID":151182,"lastUser":{"userID":151182,"name":"ajuelsgaard","url":"https:\/\/community.smartsheet.com\/profile\/ajuelsgaard","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!jD9qI_ZEy_o!ZBFrGdYxZ3o!H7BDI1juIh8","dateLastActive":"2023-09-28T17:28:44+00:00","banned":0,"punished":0,"private":false,"label":"✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":2,"countViews":13,"score":null,"hot":3391839644,"url":"https:\/\/community.smartsheet.com\/discussion\/110932\/i-am-trying-to-convert-a-formula-to-a-column-formula-and-keep-getting-the-same-error-why","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/110932\/i-am-trying-to-convert-a-formula-to-a-column-formula-and-keep-getting-the-same-error-why","format":"Rich","lastPost":{"discussionID":110932,"commentID":397491,"name":"Re: I am trying to convert a formula to a column formula and keep getting the same error. Why?","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/397491#Comment_397491","dateInserted":"2023-09-28T17:29:10+00:00","insertUserID":151182,"insertUser":{"userID":151182,"name":"ajuelsgaard","url":"https:\/\/community.smartsheet.com\/profile\/ajuelsgaard","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!jD9qI_ZEy_o!ZBFrGdYxZ3o!H7BDI1juIh8","dateLastActive":"2023-09-28T17:28:44+00:00","banned":0,"punished":0,"private":false,"label":"✭✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions"}],"groupID":null,"statusID":3,"image":{"url":"https:\/\/us.v-cdn.net\/6031209\/uploads\/O5NB4NF1D746\/image.png","urlSrcSet":{"10":"","300":"","800":"","1200":"","1600":""},"alt":"image.png"},"attributes":{"question":{"status":"accepted","dateAccepted":"2023-09-28T17:28:51+00:00","dateAnswered":"2023-09-28T17:01:19+00:00","acceptedAnswers":[{"commentID":397484,"body":"

You cannot use hardcoded row numbers in a column formula. change each 1 to @row. <\/p>

[Column Name]@row<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[]},{"discussionID":110909,"type":"question","name":"MULTIPLE IF FORMULA AROUND DATES","excerpt":"Hi: Can anyone help with a Multiple If formula which i cannot get to work please? I have a Valid To Culumn with a date in it and have a Status Column i want toi flag as CURRENT, EXPIRING or EXPIRED depending on the date. I had CURRENT & EXPIRED working but when i try to include the additional IF to show as EXPIRING if the…","snippet":"Hi: Can anyone help with a Multiple If formula which i cannot get to work please? I have a Valid To Culumn with a date in it and have a Status Column i want toi flag as CURRENT,…","categoryID":322,"dateInserted":"2023-09-28T10:01:20+00:00","dateUpdated":null,"dateLastComment":"2023-09-28T10:26:39+00:00","insertUserID":141269,"insertUser":{"userID":141269,"name":"Fialko66","url":"https:\/\/community.smartsheet.com\/profile\/Fialko66","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-09-28T10:24:41+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":null,"lastUserID":141269,"lastUser":{"userID":141269,"name":"Fialko66","url":"https:\/\/community.smartsheet.com\/profile\/Fialko66","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-09-28T10:24:41+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":2,"countViews":23,"score":null,"hot":3391793279,"url":"https:\/\/community.smartsheet.com\/discussion\/110909\/multiple-if-formula-around-dates","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/110909\/multiple-if-formula-around-dates","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":110909,"commentID":397374,"name":"Re: MULTIPLE IF FORMULA AROUND DATES","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/397374#Comment_397374","dateInserted":"2023-09-28T10:26:39+00:00","insertUserID":141269,"insertUser":{"userID":141269,"name":"Fialko66","url":"https:\/\/community.smartsheet.com\/profile\/Fialko66","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-09-28T10:24:41+00:00","banned":0,"punished":0,"private":false,"label":"✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-09-28T10:25:42+00:00","dateAnswered":"2023-09-28T10:22:57+00:00","acceptedAnswers":[{"commentID":397373,"body":"

Hi @Fialko66<\/a>,<\/p>

Try this:<\/p>

=IF(AND([Valid To Date]@row < TODAY(30), [Valid To Date]@row > TODAY()), \"EXPIRING\", IF([Valid To Date]@row >= TODAY(), \"CURRENT\", \"EXPIRED\"))<\/p>

Sample:<\/p>

\n
\n \n \"image.png\"<\/img><\/a>\n <\/div>\n<\/div>\n

Hope this helps - if I've misunderstood something or you've problems\/questions then just post! 🙂<\/span><\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[{"tagID":254,"urlcode":"formulas","name":"Formulas"}]}],"initialPaging":{"nextURL":"https:\/\/community.smartsheet.com\/api\/v2\/discussions?page=2&categoryID=322&includeChildCategories=1&type%5B0%5D=Question&excludeHiddenCategories=1&sort=-hot&limit=3&expand%5B0%5D=all&expand%5B1%5D=-body&expand%5B2%5D=insertUser&expand%5B3%5D=lastUser&status=accepted","prevURL":null,"currentPage":1,"total":10000,"limit":3},"title":"Trending in Formulas and Functions ","subtitle":null,"description":null,"noCheckboxes":true,"containerOptions":[],"discussionOptions":[]}">

Trending in Formulas and Functions