Answered

Need to create a TDEE (daily calorie expenditure) Calculator


Userlevel 1

I’m looking to create a TDEE Calculator where the clients give me their age, height (in inches), weight (lbs), and activity level (the 5 different options then would = a number assigned for calculation). 

This would save me a ton of time for my clients vs having to do it manually. I have seen @amy.carlson’s BMI calculator from a year ago and tried to use that as reference, but after trying this now multiple times unsuccessfully, I wanted to reach out here to see if anyone could help!

Appreciate your time and any feedback,

Jace

icon

Best answer by john.desborough 6 January 2022, 22:46

View original

20 replies

Userlevel 7
Badge +6

@jacef - welcome to the community. 

if you want to share some of the logic, we maybe able to help you work through it. 

 

des

Userlevel 1

Idk exactly what you mean by the logic.. if you mean what I tried or how it would need to be calculated. To calculate for TDEE (total daily energy expenditure I would need to ask the following questions for the following equation.

First I’ll need to find BMR (basil metabolic rate),

The equations for males and females are: 

Men: (10 × weight in kg) + (6.25 × height in cm) - (5 × age in years) + 5

Women: (10 × weight in kg) + (6.25 × height in cm) - (5 × age in years) - 161.

 

Then I will need to take this outcome and multiply it by a score that’s associated with their activity level (see below). So there will be a multiple choice question with the following answers and scores:

To calculate approximate TDEE, simply multiply these activity factors by your BMR:

  • Sedentary (little to no exercise + work a desk job) = 1.2
  • Lightly Active (light exercise 1-3 days / week) = 1.375
  • Moderately Active (moderate exercise 3-5 days / week) = 1.55
  • Very Active (heavy exercise 6-7 days / week) = 1.725
  • Extremely Active (very heavy exercise, hard labor job, training 2x / day) = 1.9
Userlevel 7
Badge +6

@jacef  - that is perfect in terms of being able to take a stab to show how it ‘should’ work. I am tied up in a call for the next 2 hours but will try to put something together to show you how i would approach it .. 

 

back soon

des

Userlevel 7
Badge +6

@jacef - i did three different variations of the form as follows and got the same output at 2 decimal level - it seems that it won’t go beyond that at this time in the form.. approaches and comments: 

  1. this version rounded the input variables for the activity level multiplier up to two digits ie 1.375 became 1.38 when i tried to enter the 3 digits into multiplier field (see image
  1. this version i initially multiplied the activity variables by 1000 to start with so that they were not three decimal places long, and then divided the results by 1000 to see if it would not end up with result at two decimals (see image) 
  1. in this version, i tried to create variables for the 5 activity levels at the 3 decimal points in the value but it rounds them up to 2 digit.. 

 

the only way around the two activity multipliers that i can think of is to calculate along the lines as follows (using 1.375 as example) 

  • multiply bmr by 1.37 and add result to v_LA 
  • multiply bmr by 1.38 and add result to v_LA 
  • divide v_LA by 2 to get the average 

however, i believe the output will still be limited to two decimal points which may end up with the same rolled up .. and i have run out of time to test that today.. i will leave you to think it through.. 

 

have a look at these three samples and tell me if i got it in the ballpark - understanding there will be a rounding error .. i can walk you through the logic in screen shots if that is where you are heading

 

des

Userlevel 7
Badge +5

Hi @jacef I hope you’re having a great week and Friday! Were you able to implement @john.desborough ‘s solution? 

Userlevel 1

I was, Thanks!

Userlevel 7
Badge +5

Glad to hear, @jacef !! Let us know if we can help with anything else. :grinning:

Userlevel 2

Guys I’ve created a calorie calculator using typeform that outputs the TDEE and also the clients starting calories in accordance with their goals.

I used the same BMR equation that @jacef used, and the same activity levels that you used albeit 1.375 was rounded up to 1.38 and 1.725 was rounded up to 1.73.

You can also check out a screen grab of the Logic which you’ll find really helpful. I’ll add a Vimeo link here so you can check it out for yourself.

Sorry about the quality of the video, but hopefully it’s clear enough 🙌 

 

 

Userlevel 7
Badge +5

Thanks for sharing this, @iamlouismullen !! Do you mind if I try out the form? :grin:

Userlevel 2

Thanks for sharing this, @iamlouismullen !! Do you mind if I try out the form? :grin:

Yeah go for it!

Although, I’ve create a much more thorough one that then links to my active campaign too!

 

 

Hey! Thanks to everyone on this thread it’s so helpful! I’m having an issue and I can’t for the life of me figure it out. 

How do you get your end screen to display the results from the calculator to people who complete the form?

I have run tests and it doesn’t currently display anything other than the generic “thank you”.

Userlevel 7
Badge +5

Hi @hsmith13 This article here can help you with showing the correct ending. 😀 Let us know if you run into any troubles following the steps. 

 Hello- 

 

I’m so grateful someone was able to create a form with TDEE. Is anyone able to help make a form just like this but that also calculates macronutrients such as Carbs, Protein & Fat based on their TDEE answers?

 

Thank you!

Userlevel 7
Badge +6

@Katie Scott - if you have the ‘formulae’ on a napkin, the logic can be created to render the details - or at least it should ie if the calories are 2400 and you want 30-30-40 split, the math is simple.. 

 

des

Hi gang, I’m struggling a bit with the how to set things up here. To keep this as simple as possible let’s just say I have an open text entry (number) where someone can enter their weight in lbs. Great. No problem. How do I create a variable that’ll store that entry squared?

Example: Weight entered = 180 (I can store that as a variable of @weight)
I know I can create another variable @weight2 but how do I tell Typeform that @weight2 is @weight X @weight?

Thank you

Userlevel 7
Badge +6

@Lifestyle180 

  • make sure you are using a number field and not a text field - just a pedantic moment there.. 

 

  • if weight is greater than 0 then add weight to to @weight2
  • if weight is greater than 0 then multiply @weight2 by weight

if you do that you will get the square.. 

 

des

This is a really great thread.  I am working on building a calorie calculator for my landing page in Typeform.  Any suggestions on how to have the results trigger a conditional notification with a meal plan template attachment?

Userlevel 7
Badge +5

Hi @Debbie How are you currently measuring results from the form? Or, what are the different triggers in the form for different meal plans? Any additional information you can provide about your form or ideal setup would be helpful!

Thank you @john.desborough  - you wrote …

  • if weight is greater than 0 then add weight to to @weight2
  • if weight is greater than 0 then multiply @weight2 by weight

if you do that you will get the square.. 

= = = = =

That’s kind of what seems odd to me. I understand I’ll “get the square” from that. But is the square then stored as @weight2? What an odd way for Typeform to assign a variable if so.

 

Of course as all of us who build calorie and BMI calculators do - we’ll need to do some additional calculating. 

 

One such formula for BMI is you take weight in kg divided by height in meters squared.

 

So I’m just trying to understand how Typeform stores variables so that these simple calculations can be handled. I’m very used to working with variables and doing these calculations but it seems Typeform handles this in an odd way (or it’s just me).

 

Userlevel 7
Badge +6

@Lifestyle180 - it’s an odd thing.. it took a while to figure it out but yes, not the way you do it in some application domains. 

.. yes the square is stored in the @weight2 variable ….. 

and i understand the issues on the calculations.. it’s one of the things that i did as example about 2 years ago in here when someone was looking at how to make the calculations work. here’s the sample

I’ve built out about 20 different versions for folks, using typeform, who got hung up on the same issues for calculating and using variables .. after a while it becomes second nature.. 

 

des

Reply