• New Commercial Services Section

    We have now opened a commercial services section here on the forum. If you have a Fabrik project that you wish to have someone work on for you, post it under Help Wanted. If you are an application developer and wish to earn some money helping others, post your details under Fabrik Application Developers.

    Both of these are unmoderated. It will be up to both parties to work out the details and come to an agreement.

[Solved]How to calculate diff date in fabrik

for this calculation,should I use validation in the third field?
the third field is to show the value of the calculation
or should i used calc plugin.
thank u
 
It entirely depends on what you want to do, what the purpose of the calculation is, what you need the difference for.
You can use it with a validation. Or you can use it in a calc field simply for display, or other things.
 
I want to display the value in the third field after the calculation. value only display on the list after submitting the save button. thank u
 

Attachments

  • value.png
    value.png
    4.1 KB · Views: 156
Aaaaahhh... so it's in a form...
Please understand, we're all terrible mind readers here... :rolleyes:

Well, since I guess the element will be "read-only", you could probably use the notes element and the JS pointed at by @amitfalana in his/her post here above.
eheheh sorry.

yes the element is read-only and I want to display the value after the calculation.means when I enter the value in the field1 and field 2.the value in the third field auto display.i have already put the calculation in the third field
 
If you already have the calculation in the third field (assuming in calc element), just enable "ajax calculation" and in "Ajax observe field" enter: {mytable___field2}
Obviously change the table name and field name to match yours.
 
thank u for your reply. When I enable ajax calculation and fill in Ajax observe field. the value still, not display in the third field.
 

Attachments

  • kontrakbulan.png
    kontrakbulan.png
    15.9 KB · Views: 141
1. Try appending _raw to both placeholders in the calculation, so it's {mytable___field_raw}.
2. Separately, and from what I understand, shouldn't you observe your 1st and 2nd fields, so that the calc field updates when you change those? You can enter multiple fields separated by comma.
 
It seems you have a space in the observe field before last closing bracket. That's enough to make it not work.

And if you want the calculation to be made when the date element changes, the observe field(s) should be the same as the date field(s). In screenshot your observe field is neither of your date fields.
 
Last edited:
It seems you have a space in the observe field before last closing bracket. That's enough to make it not work.
...which may be true for the update of the calc field output when the observed field gets changed. But the initial calc should still work and display a value -- if done right. ;)
Suggesting to first get the calc right and some result displayed.
 
the value is inserting in the table and the value is right. The third field for display value is 'tempoh_kontrak_bulan'.so I have already put the value in the observe field. the problem is I want to display the value without submitting the form.
 

Attachments

  • trkhprojek.png
    trkhprojek.png
    20.2 KB · Views: 154
  • tarikhprojek2.png
    tarikhprojek2.png
    10.6 KB · Views: 149
Nonono...

Step by step:

1. We assume you want to show in element #3 (calc) the difference in between element #1 and #2 (both date) in days -- in the form.

2. As #1 or #2 are being changed, you want #3 to dynamically update.

3. Stumbling over this only now: your placeholders are appearing wrong as they're not using the triple underscores in between table and element (= column) name. So, I'm surprised that your calculation seems to actually work.
Please refer to http://fabrikar.com/forums/index.php?wiki/placeholders/#tablename-elementname and apply this to all your Fabrik element placeholders.
(Can't see the table name in your screenshots, so let's use "xyz_mytable" here and now -- "xyz_" being the prefix.

4. Accordingly, in the calculation use correct placeholders, e.g. {xyz_mytable___tarikh_mula_projek}.

5. Aside from its format, the placeholder in the "observe" field is the wrong one . You're putting in #3 = this calc element itself... as if it's to observe itself for changes.
So, as said before, please replace the placeholder in the "observe" field with:
Code:
{xyz_mytable___tarikh_mula_projek},{xyz_mytable___tarikh_tamat_projek}
but your table name.

Please refer to the Wiki for this as well: http://fabrikar.com/forums/index.php?wiki/calculation-element
 
Last edited:
Two more things:

6. As also already mentioned, it shouldn't hurt to append "_raw" in the placeholders in the calculation. So, e.g. {xyz_mytable___tarikh_mula_projek_raw}.

7. When you're adding a new record, the calc element #3 will likely not display anything (maybe "0") on form page load. There's no record = no data = empty placeholders. You may need to first select both #1 and #2 dates for it to display a value.
 
I have one more question about the percentage calculation. I have 10 fields which are if field 1 is not empty the calculation is 'Pembayaran_pertama/Nilai Kontrak Sebenar * 100. I used the same method as above. But it doesn't work.and also affect my date picker. thank u
 

Attachments

  • payment.png
    payment.png
    15.5 KB · Views: 147
  • percentage.png
    percentage.png
    2.2 KB · Views: 151
  • calcfloat.png
    calcfloat.png
    22.7 KB · Views: 150
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top