[SOLVED] Mathematical Calculation Fields

11 years 5 months ago - 11 years 5 months ago #213707 by edmundcheong
[SOLVED] Mathematical Calculation Fields was created by edmundcheong
Are there any plugins to calculate mathematical formula or conditions.

For example cb_fieldnumbers = cb_number01 + cb_number02

Something like Microsoft Excel?

Please Log in to join the conversation.

11 years 5 months ago #213727 by krileon
Replied by krileon on topic Re: Mathematical Calculation Fields
You'd need to use CB Query Field so you can use MySQL functions to add, subtract, etc.. Example as follows.
SELECT ( `cb_number01` + `cb_number02` ) FROM `#__comprofiler` WHERE `id` = '[user_id]'


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

11 years 5 months ago #213876 by edmundcheong
Replied by edmundcheong on topic Re: Mathematical Calculation Fields
I am actually trying to do a BMI Calculator for my members.

The formula is based on the following: www.nutriweb.org.my/bmical.php

Krileon, I am quite a beginner on this. Is CB Query field something downloadable by Professional members (or do I create it at the CB Field Management Function)? Or is it just the delimiter field?

Please Log in to join the conversation.

11 years 5 months ago #213911 by krileon
Replied by krileon on topic Re: Mathematical Calculation Fields

The formula is based on the following: www.nutriweb.org.my/bmical.php

That's a simple formula that MySQL can certainly do assuming you've weight and height fields. Example query as follows.
SELECT ( `cb_weight` / ( `cb_height` * `cb_height` ) ) FROM `#__comprofiler` WHERE `id` = '[user_id]'

Is CB Query field something downloadable by Professional members

Yes, it's downloaded from the Professional downloads section.

or do I create it at the CB Field Management Function?

Once downloaded and installed, yes it's a new fieldtype so it's created via CB > Field Management.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

11 years 5 months ago #213987 by edmundcheong
Replied by edmundcheong on topic Re: Mathematical Calculation Fields
Thanks for the reply! Really appreciate it.

Now, I am using the cb conditional plugin to show a delimiter field "you are over weight" if the BMI is over 30.

Somehow cb conditional is showing "you are overweight" even though it is less then 30.. is it because that CB conditional is not be able to detect the value since its a cb query field?

Another thing is that when i get the results from such query, the decimal points are set to 14 points. example: 22.4765868886576

Please Log in to join the conversation.

11 years 5 months ago - 11 years 5 months ago #214037 by krileon
Replied by krileon on topic Re: Mathematical Calculation Fields
CB Conditional may not work properly with query fields. It expects the field to actually have stored value. So you'll probably need to use a IF substitution in your delimiter field.

[cb:if cb_query>="30"]You appear to be over weight![/cb:if]

Another thing is that when i get the results from such query, the decimal points are set to 14 points. example: 22.4765868886576

You need to use additional SQL functions to format it as needed. You can find the documentation for MySQL as follows.

dev.mysql.com/doc/refman/5.6/en/index.html

More specifically numeric functions as follows.

dev.mysql.com/doc/refman/5.6/en/numeric-functions.html


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.359 seconds

Facebook Twitter LinkedIn