Problems exporting Calculated elements in a CSV file

ahmedo

Member
Hi,

I am not sure why this is happening.

I have a list that contains calculated elements. It seems that when I export the list to CSV, those calculated elements come up with blank values.

Unless I export every element in the list, including the raw data, I do not see any value in this calculated elements.

Where have I gone wrong?
 
Do the calculated values actual have data in the underlying table?

One potential issue with calcs is, if you add the calc after you have existing data, your calc'ed values will show in form and list views, but won't actually exist in the underlying table until the form is edited and saved.

-- hugh
 
Thanks Hugh. The calculated elements have values stored in them. I checked in my phpMyAdmin. The fact that if I select all data including raw data to be shown, those calculated elements do show values. Only when I chose Selected or Shown, then the values disappear. With regards to the second point, the calc fields were added before we entered any record.

Very weird.
 
OK, I finally managed to replicate this, or at least what I assume is the cause.

If I have my calc set with "Calc on Save Only" set to "No" (so it re-calcs on a list load), and I do a CSV export which doesn't include elements that the calc uses, it won't work 'cos it doesn't have the data for those other elements.

So, I have a 'fullname' calc which does ...

Code:
return '{members___lastname}, {members___firstname}';

If I exclude firstname and lastname from the export, it won't work. In my case, I get the un-substituted text, literally "{members___lastname}, {members___firstname}" in the CSV. If yours are empty, I assume you are doing some kind of mathematical calc.

Basically, when doing a "selected elements" CSV export, we only include those selected elements in the query.

The only way round it is to either include the elements you calc references in the export, or set your calc's "Calc on Save Only" to "Yes", so it uses the stored value, and doesn't try and re-calc from scratch with data it doesn't have.

-- hugh
 
Thank Hugh. I think I figured out the reason why it won't export that data, and I came up with a similar conclusion. However, I tried the Calc on Save on my Fabrik test site, and I got 0 (zero) output on the calc field, as my calc field relies on the value of other fields including. The problem is that I cannot allow the export of all the elements as some of them include data that I do not want everyone to see. In fact, some of the fields are hidden.

I will figure out a way. I am taking online courses covering PHP and MySQL now. There is still a long way for me to go. As I said, this is a one year mission. And I am pleased, especially by the support here.
 
However, I tried the Calc on Save on my Fabrik test site, and I got 0 (zero) output on the calc field, as my calc field relies on the value of other fields including

If you set that option to Yes, what that means is that the calc is ONLY calculated when you save the form. When we display list view (or CSV output), we just use the value stored in the table (calculated when the form was submitted). So if you have values in your table (which we established you do), they should definitely be exported, with that option set to Yes.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top