Bir poz listesinden fiyat değerini formüle eklemek
-
Liste (fieldname1)
Açıklama – Değer
Poz1: 15$
Poz2: 20$
Poz3: 40$
Poz4: 26$
Poz5: 15.5$Listedeki açıklama değerine göre bir hesaplamada değerleri kullanmak istiyorum. Bu mümkün mü?
Hesaplama (fieldname2)
(10+20)*IN(‘Poz2’,fieldname1)
= (10+20)*20 = 600$Daha sonra fieldname1 değerlerini değiştirdiğim zaman hesaplama kısmını değiştirmem gerekmesin.
-
Hello @metesey
The process is more simple. You can enter the numbers only (15, 20, 40, 26, and 15.5) in the choices’ values (note they are used only for calculations, you can configure the field to submit the choices’ texts), and then insert a calculated field in the form and enter the equation:
(10+20)*fieldname1
or simply:
30*fieldname1
Best regards.
Hello @metesey
By the way, the plugin sums by itself the values of the ticked choices in the checkbox field, but if you disabled this feature from the checkbox field’s settings, its value would be an array with the values of the ticked choices, and in this case, you must make the sum explicitly, and the equation needs to be edited as follows:
30*SUM(fieldname1)
Best regards.
2024 Yılında
Liste (fieldname1) – Hidden
Açıklama – Değer
Poz1: 15$
Poz2: 20$
Poz3: 40$
Poz4: 26$
Poz5: 15.5$Tam anlatamadım galiba. Aslında benim istediğim ücretleri bir listeye gireceğim, sonra formülde o açıklamaya karşılık gelen değeri alayım. Kullanıcılar bu ücretleri görmeyecek ve her yıl güncellenecek.
Hesaplama-1
(10+20)*IN(‘Poz2’,fieldname1)
= (10+20)*20 = 600$Hesaplama-2
(10+10+5)*IN(‘Poz3’,fieldname1)
= 25*40 = 1000$Hesaplama-3
(10+10)*IN(‘Poz1’,fieldname1)
= 20*15 = 300$——————————
2025 Yılında
Liste (fieldname1) – Hidden
Açıklama – Değer
Poz1: 20$
Poz2: 25$
Poz3: 45$
Poz4: 31$
Poz5: 20.5$yani yıllar değiştiği zaman listedeki fiyatları oluşturacağım. Hesaplamalar buna göre güncellenecek.
Hesaplama-1
(10+20)*IN(‘Poz2’,fieldname1)
= (10+20)*25 = 750$Hesaplama-2
(10+10+5)*IN(‘Poz3’,fieldname1)
= 25*45 = 1125$Hesaplama-3
(10+10)*IN(‘Poz1’,fieldname1)
= 20*40 = 400$Hello @metesey
In this case, if fieldname1 is a checkbox field with the choices values: Poz1, Poz2, Poz3, Poz4, and Poz5, and you want to implement the equation of the Hesaplama-1 field as follows:
If the Poz2 choice is ticked in feldname1 the equation’s result would be: (10+20)*20 and zero if not.
First, I recommend inserting an “HTML Content” field in the form to define the object with choices’ values (it allows you to edit the prices in only one place)
<script>
values = {'Poz1': 15, 'Poz2': 20, 'Poz3': 40, 'Poz4': 26, 'Poz5': 15.5};
</script>And edit the equation in the calculated field as follows:
(10+20)*IF(IN('Poz2', fieldname1|r, values['Poz2']), 0)
You can follow a similar logic with the other equations.
Best regards.
Teşekkürler formülü aşağıdaki gibi kullandım. Fiyatları tek yerden kontrol etmek için.
HTML İçeriği
<script>
values = {‘Poz1’: 15, ‘Poz2’: 20, ‘Poz3’: 40, ‘Poz4’: 26, ‘Poz5’: 15.5};
</script>Hesaplama
(10+20)*values[‘Poz2’]
İyi çalışmalar dilerim.
Hello @metesey
Yes, that’s fine, but if you want to evaluate the equation based on the fieldname1 choice selected you must include it in the equation.
Best regards.
Merhaba son bir soru daha soracaktım. Başka hesaplamadaki değeride alabiliyormuyuz.
Örneğin
(10+20)*values[‘Poz2’]
yerine
(10+20)*[CP_CALCULATED_FIELDS id=”1″ values[‘Poz2’]]
veya
(10+20)*[CP_CALCULATED_FIELDS id=”7″ values[‘Poz2’]]
gibi.
İyi çalışmalar dilerim.
Hello @metesey
If you have two forms on the page, you can assign class names to them via their shortcodes:
[CP_CALCULATED_FIELDS id="1" class="class-a"]
[CP_CALCULATED_FIELDS id="7" class="class-b"]And assuming you want to use the value of the field in form with class-a in the equations of form-b, you can enter an equation similar to the following one:
(10+20)*getField(fieldname2|n, '.class-a')
The equation multiplies the (10+20) by the value of the field with name fieldname2 in the form with class class-a.
Best regards.
class=”class-a” kodlarını nereden ekliyoruz, kısa kodlardan mı?
Benim elimde bir fiyat listesi olacak bunu bir hesaplama sayfasına “HTML İçeriği” olarak aşağıdaki gibi yazmak istiyorum.;
<script>
values = {'Poz1': 15, 'Poz2': 20, 'Poz3': 40, 'Poz4': 26, 'Poz5': 15.5};
</script>Bundan sonraki hesaplamalarda ise bu fiyatları çekip kullanmak istiyorum. Fiyatlar sadece bir hesaplama formunda olacak. Ben bunu değişik hesaplamalarda kullanmak istiyorum.
Örneğin:
getField(fieldname1|n, ‘.class-a’).setChoices(values: [‘Poz2’])*7.85*2
ama bu class’ı nasıl atayacağım ve values değerlerini nasııl çekeceğim onu beceremedim.
Hello @metesey
For multiple forms on the page, you cannot use the same “values” variable name on them. The “values” variable in the last form would overwrite others.
I honestly do not understand why you are making the process so complex. What do you want to implement exactly? Could you please describe the project in English? I think I’m losing something by translating the texts.
Best regards.
Hello.
Your calculation plugin is very nice and helps me to make flexible calculations. But I still need your help to solve some issues more easily.
Let me try to explain my project in more detail.
I want to create a price list to be used in later forms. The prices in this list will be updated every month. If I write these prices in each form, I will have to update all forms when updating prices. However, when I correct the prices only in a list, I want these prices to be updated in all forms (calculations) if possible;
FORM 1: UNIT PRICES
fieldname1: “HTML Content” or else<script>
values = {‘Cost1': 15, 'Cost2': 20, 'Cost3': 40, 'Cost4': 26, 'Cost5': 15.5};
</script>FORM 2: BATHROOM COST CALCULATION
fieldname1: Bathroom field
fieldname2: Wall height
fieldname3: fieldname1*Cost2
fieldname4: (fieldname1+fieldname2)*Cost3
fieldname5: fieldname3+fieldname4
FORM 3: KITCHEN COST CALCULATION
fieldname1: Cabinet length
fieldname2: Cabinet height
fieldname3: (fieldname1+fieldname2)*Cost3
FORM 4: WC COST CALCULATION
…
FORM 5: ROOF COST CALCULATION
…
Since I make calculations in different forms, how can I write formulas so that when the prices are updated, instead of opening each form and updating the prices in the calculations, I will update the prices on a sheet and with this update, the calculations in all forms will be updated?Hello @metesey
The behavior you describe can be implemented by using the DS fields distributed with the Developer and Platinum plugin versions.
The DS fields read their values from external data sources like CSV files, databases, other submissions, ACF, etc.
You can create the prices list in a CSV file (You can even use Google Sheets and publish the Google Sheets document in CSV format) and use it from the forms by using the DS fields.
Implementing the forms in this way allows you to update the price list in one place. The forms would use the new prices without modifying the forms.
So, assuming you have a CSV file with the columns: name, value
name,value
Cost1,15
Cost2,20
Cost3,40
Cost4,26
Cost5,15.5Now, in the form, you can insert a RecordSet DS field to read the CSV file from its URL. To describe the process I’ll call it fieldname123.
The equations in “FORM 2: BATHROOM COST CALCULATION” can be implemented as follows:
fieldname3 equation:
(function(){
let prices = fieldname123;
for( let i in prices ) {
if(prices[i]['name'] == 'Cost2') return fieldname1*prices[i]['value'];
}
})()fieldname4 equation:
(function(){
let prices = fieldname123;
for( let i in prices ) {
if(prices[i]['name'] == 'Cost3') return (fieldname1+fieldname2)*prices[i]['value'];
}
})()Learn more about the DS fields by reading the following blog post:
https://cff.dwbooster.com/blog/2019/02/14/ds
Best regards.
Tamam, ilginiz için teşekkür ederim.
- You must be logged in to reply to this topic.