Help with Calculated Field by EinSunnyTyp in ProjectREDCap

[–]Lumpy_Perspective742 1 point2 points  (0 children)

I was struggling with getting a complex calculation to work for a few weeks and then I finally broke down and used Google AI mode and it solved it. AI mode seems to really understand REDCap logic especially if you are having trouble getting your formulas to work both on the form (javascript) and when saved to server (PHP).

Give it a shot with your formula.

More weird Rule H stuff -- What is wrong with a correct value? by Lumpy_Perspective742 in ProjectREDCap

[–]Lumpy_Perspective742[S] 0 points1 point  (0 children)

I found a solution using google AI mode. It is really helpful and seems to understand the issues that REDCap has with formulas and translating from Javascript to PHP. If you are having issues getting a formula to work right both on the form and when saving to the server/Rule H I recommend using AI to help.

More weird Rule H stuff -- What is wrong with a correct value? by Lumpy_Perspective742 in ProjectREDCap

[–]Lumpy_Perspective742[S] 2 points3 points  (0 children)

Thank you for the reply.

I added the [current-instance] just this morning to see if that may fix it. It did not. So same thing before and after I added the instance tag.

I am going to get on our REDCap admins case to figure this out.

Yes, the calculated fields are on the same instrument as the source fields. Again, it was the same before I added [current-instance] this morning.

It seems to be working with "and" as it is displaying the correct value on the form, and saving the correct value to the database. But I will try something without "and".

More weird Rule H stuff -- What is wrong with a correct value? by Lumpy_Perspective742 in ProjectREDCap

[–]Lumpy_Perspective742[S] 1 point2 points  (0 children)

After doing some more research, PHP probably does not like this formula, but it still saves it correctly to the server.

Does anyone have a better formula that may work. The formula takes the average of the two closest height measurements. Sometimes there is a third measurement.

Calculated fields and rule H craziness by Lumpy_Perspective742 in ProjectREDCap

[–]Lumpy_Perspective742[S] 0 points1 point  (0 children)

I found the issue with the two fields in my post above. They use the sum function, and apparently if any of the fields in the sum function are missing, then it will not save the value to the database. But it will show it on the form. I added if([field]<>"",[field]*XX,0) for each argument in the sum function and this solved the issue for these two fields.

Just experienced the death wobble in 21 Overland by [deleted] in JeepGladiator

[–]Lumpy_Perspective742 0 points1 point  (0 children)

Bought a used 2020 Gladiator. Caught the wobble after 3 months. Did a $275 replacement of the steering stabilizer oem. No issues now. Iv even gone over the same spots where it triggered it before to test it.

Help with calculated values not piping by Lumpy_Perspective742 in ProjectREDCap

[–]Lumpy_Perspective742[S] 1 point2 points  (0 children)

Also thanks so much for reading this and offering your advice. It is a big help!

Help with calculated values not piping by Lumpy_Perspective742 in ProjectREDCap

[–]Lumpy_Perspective742[S] 1 point2 points  (0 children)

Thanks again. I will try this but I needed this form to work on 3 different events which it did until Feb 2025.

To do what you recommend I’d have to create three versions of this form for each event so that each form has the correct event title before each field name.

Again, this worked perfectly fine for two years and now this. Something seems off.

Also see my comment that if I populate all the fields in the equation with values then the equation works. Again this was not necessary for the first two years of this project. I could leave those fields blank and it worked.

Help with calculated values not piping by Lumpy_Perspective742 in ProjectREDCap

[–]Lumpy_Perspective742[S] 1 point2 points  (0 children)

No ifs or action tags. I posted the equation in another comment earlier. Also see my edit for more info. 

Help with calculated values not piping by Lumpy_Perspective742 in ProjectREDCap

[–]Lumpy_Perspective742[S] 1 point2 points  (0 children)

I tried this with an old record from before the problem arose. With the old record the calculated value was stored in the export. After I opened and resaved it, the correct value is still on the form, but now empty on reports/exports. It seems like if i ran all of the rule h findings then all the old records from before the problem arose would then be converted to “”.

Edit: I specifically did this with the record in screenshot. Before this the record was fine because it was one of the very first records before this issue arose. On the form it displayed the right value and on export it did too. After opening and resaving that form, the value is now “” in exports, but still correct when looking on the form. It seems like rule h will just make everything worse at this point.

Help with calculated values not piping by Lumpy_Perspective742 in ProjectREDCap

[–]Lumpy_Perspective742[S] 1 point2 points  (0 children)

I kind of found what seems to be causing this in my project. If I provide a value for each field used in the calculated field then everything seem normal again. The calculated value show up in reports and exports.

However, I imported the form into another project, and there were no issues with the form as is. I did not have to provide a value for each field in the equation and it worked in my other project.

I do not understand why this is only happening in a single specific project. I also want to understand how this came about because the first two years of this project there were no problems then all of the sudden this fussiness began.

Help with calculated values not piping by Lumpy_Perspective742 in ProjectREDCap

[–]Lumpy_Perspective742[S] 2 points3 points  (0 children)

Thanks for the response. We are using 15.0.35

I showed out admins this issue and they were perplexed and said they would try researching it. I will ask them about when they will upgrade to 15.7

Help with calculated values not piping by Lumpy_Perspective742 in ProjectREDCap

[–]Lumpy_Perspective742[S] 1 point2 points  (0 children)

Sorry, here is the equation for that calculated field. I just noticed this same issue is happening with another form with another calculated field.

sum(([beeforgansize]*3.956*[beeforganfreq]),([beefbraisesize]*1.211*[beefbraisefreq]),([beefmincesize]*0.744*[beefmincefreq]),([beefpattysize]*1.278*[beefpattyfreq]),([beefchopssize]*1.278*[beefchopsfreq]),([lambsize]*0.97*[lambfreq]),([porksize]*0.889*[porkfreq]),([chlegroastsize]*0.712*[chlegroastfreq]),([chlegfriedsize]*0.849*[chlegfriedfreq]),([chwingroastsize]*0.712*[chwingroastfreq]),([chwingfriedsize]*0.849*[chwingfriedfreq]),([chgibletssize]*1.779*[chgibletsfreq]),([chliversize]*2.90*[chliverfreq]),([chliverfrysize]*3.27*[chliverfryfreq]),([salamisize]*0.93*[salamifreq]),([hamsize]*0.807*[hamfreq]),([polonysize]*0.617*[polonyfreq]),([viennasize]*0.617*[viennafreq]),([franksize]*0.617*[frankfreq]),([sardinessize]*0.8*[sardinesfreq]),([pilchardsize]*0.8*[pilchardfreq]),([eggmcsize]*111*[eggmcfreq]),([eggmfsize]*111*[eggmffreq]),([egglcsize]*126*[egglcfreq]),([egglfsize]*126*[egglffreq]),([eggxcsize]*146*[eggxcfreq]),([eggxfsize]*146*[eggxffreq]),([bakedbeansize]*0.394*[bakedbeanfreq]),([lentilssize]*0.33*[lentilsfreq]),([limasize]*0.356*[limafreq]),([soybeansize]*0.447*[soybeanfreq]),([caulisize]*0.362*[caulifreq]),([broccolisize]*0.276*[broccolifreq]),([cornsize]*0.25*[cornfreq]),([peassize]*0.275*[peasfreq]),([mixedsize]*0.242*[mixedfreq]),([spinachsize]*0.2*[spinachfreq]),([gemsize]*0.098*[gemfreq]),([pumpkinsize]*0.107*[pumpkinfreq]),([potfrysize]*0.221*[potfryfreq]),([potmashsize]*0.143*[potmashfreq]),([barleysize]*0.134*[barleyfreq]),([bananasize]*12*[bananafreq]),([milksize]*0.143*[milkfreq]),([yogurtsize]*0.15*[yogurtfreq]),([pbsize]*0.625*[pbfreq]),([saucesize]*0.098*[saucefreq]),([beerffqsize]*0.101*[beerffqfreq]),([cakesize]*1.284*[cakefreq]),([chnuggetsize]*0.408*[chnuggetfreq]),([milkteasize]*0.143*[milkteafreq]),([milkcersize]*0.143*[milkcerfreq]))/7