Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Intro Black Friday Offer for a lifetime*

[SOLVED] Mathematical Calculation Fields

12 years 3 weeks ago - 12 years 2 weeks 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?
Last edit: 12 years 2 weeks ago by krileon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48556
  • Thanks: 8292
  • Karma: 1445
12 years 3 weeks 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.
Code:
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 or Create an account to join the conversation.

12 years 3 weeks 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 or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48556
  • Thanks: 8292
  • Karma: 1445
12 years 3 weeks 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.
Code:
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 or Create an account to join the conversation.

12 years 3 weeks 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 or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48556
  • Thanks: 8292
  • Karma: 1445
12 years 3 weeks ago - 12 years 3 weeks 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.
Last edit: 12 years 3 weeks ago by krileon.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum