Topic: Need help to create a calculated field

I want to know the total charges incurred in a surgical procedure. I need to deduct the same from the payment received to get the doctor's fees. My calculated field for total charges is giving errors. Please help.

Post's attachments

Attachment icon CataractSx.zip 330.2 kb, 268 downloads since 2021-04-11 

Re: Need help to create a calculated field

Hello,
If I delete the calculated field for doctor's fees the programme runs, but the sum function in cf_totalcharges does not work. How to do this correctly?

3 (edited by sibprogsistem 2021-04-14 05:31:05)

Re: Need help to create a calculated field

eyeman303 wrote:

I want to know the total charges incurred in a surgical procedure. I need to deduct the same from the payment received to get the doctor's fees. My calculated field for total charges is giving errors. Please help.

what should be equal to  where LU_001_Charges.id =   ?

4 (edited by eyeman303 2021-04-14 14:53:55)

Re: Need help to create a calculated field

Hi Sibprogsistem,
When Charges are selected in AA_002_BillBreakup, they are saved in table AA_002_BillBreakup., which has foreign keys from tables LU_001_Charges and AA_001_SurgeryBill. Now I want to know the total charges incurred for a particular AA_001_SurgeryBill.id. So I felt that where LU_001_Charges.id = ( select id_LU_001_Charges from  AA_002_BillBreakup
where id_AA_001_SurgeryBill = AA_001_SurgeryBill.id)). However this only selects the first charge and sum function does not work.
Regards,
Eyeman

Re: Need help to create a calculated field

Hi Eyeman, Hi Sibprogsistem,
I've changed the calculated field calculations for both the total charges and the doctor's fees.  Does this work now for you?
Derek.

Post's attachments

Attachment icon cataracts fixed.zip 343.07 kb, 325 downloads since 2021-04-15 

6 (edited by eyeman303 2021-04-16 16:22:37)

Re: Need help to create a calculated field

Hello Derek,
Your solution is perfect as always. Here I have noted 2 new concepts.
First, AND operator is used for calculated field cftotalcharge. Is it because the table AA_002_BillBreakup contains only foreign keys? Also both tables AA_002_BillBreakup and LU_001_Charges are included under “from”.
Secondly, a calculated field cannot be used in creating an expression for another cal. field ( cfdoctorsfee) and the whole expression for the referenced cal. field (cftotalcharge) must be written.
Thank you a ton,
Eyeman

7 (edited by derek 2021-04-16 16:41:35)

Re: Need help to create a calculated field

Hi Eyeman,
1.  You need to write it like that because there is no direct link between aa_001_surgerybill and lu_001_charges.  Therefore you need to use aa_002_billbreakup as well and then specify the relationship between aa_001_surgery bill and aa_002_billbreakup and then the relationship between aa_002_billbreakfup and lu_001_charges.  If you don't do that extra bit, then the calculated field would only retrieve the value for the first of the charges rather than the sum of all of them (which was your original issue).
2.  You're correct - you can't reference a calculated field in another calculated field (but it's not usually a problem because all you need to do is repeat the whole expression (usually with some sort of bracketing)).
Glad it helped,
Derek.

Re: Need help to create a calculated field

Hello Derek,
Thanks again for explaining the concept so lucidly. I always learn something new from your posts.
Eyeman

Re: Need help to create a calculated field

Please help me with the query I can't figure out the calculation field in any way sad
MySQL database
There is a start date and an end date for the period. How to make it so that when the period from beginning to end exceeds more than 3 months, the status changes and the cell turns red
Help please

Post's attachments

Attachment icon Data.rar 293.3 kb, 276 downloads since 2021-04-19 

Re: Need help to create a calculated field

senseyesenseye1983,
If I understand correctly see attached.

Post's attachments

Attachment icon Data Period Check.zip 337.88 kb, 267 downloads since 2021-04-20 

Re: Need help to create a calculated field

ehwagner wrote:

senseyesenseye1983,
If I understand correctly see attached.

I understand that in order to calculate the remainder to the end date, you need to put if (StrToDate(s Date) - now) only where ? Please tell me

Re: Need help to create a calculated field

That is it turns out you need to connect today's date with enddate so that the result turns red those records that do not have 3 months from today's date to enddate

Re: Need help to create a calculated field

Again, I am not sure I totally understand, but I put in a calculated field to calculate the days left from now till the end date.

Post's attachments

Attachment icon Data Period Check Revised.zip 338.17 kb, 261 downloads since 2021-04-20 

Re: Need help to create a calculated field

ehwagner wrote:

Again, I am not sure I totally understand, but I put in a calculated field to calculate the days left from now till the end date.

Thank you for your help friend. And one more point if you need to specify, for example, not days, but for example the remainder of years, months, days from today's date to the end date, how do you implement this?

Re: Need help to create a calculated field

The fact is that I have a program on mysql and a calculated field to calculate from today's date to enddata the condition if it exceeds 5 years then the status is yes if it is less than 5 years then the status is no Please help me
here I created a calculated field but it does not work on mysql sad (case                                                       
when (julianday(enddate) - 1826) < (julianday("now")) then "YES"
else "NO "
end)

Re: Need help to create a calculated field

For MySql use the DateDiff function.

DateDiff(enddate,startdate)

Re: Need help to create a calculated field

ehwagner wrote:

For MySql use the DateDiff function.

DateDiff(enddate,startdate)

I probably spelled it wrong ?
when (DateDiff(enddate) - 1826) < (DateDiff ("now")) then "YES"
else "NO "
end)
Please write the whole function

Re: Need help to create a calculated field

you need to make a selection in the Grid how many days are left until enddata ( despite the fact that today's date will constantly shift) In the Grid there is only the end date all I can not add the result from the system date to enddata

Re: Need help to create a calculated field

all thanks very much to you figured out now tints in red those records that have more than 7 years from the beginning of today's date to the end date. But the question remains how to attach the status to this event so that the status is Yes or No in a separate column

Post's attachments

Attachment icon grid.rar 293.29 kb, 275 downloads since 2021-04-22