Jump to content

Search the Community

Showing results for tags 'calculated field'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Caspio Bridge
    • Caspio Apps for Ukraine
    • General Questions
    • Caspio JavaScript Solutions
    • Tables, Views and Relationships
    • Import/Export and DataHub
    • DataPages
    • Deployment
    • Security, Authentications, Roles, SAML
    • Styles and Localizations
    • Parameters
    • API and Integration
    • Calculations and aggregations
    • User JavaScript and CSS Discussions

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


MSN


Website URL


ICQ


Yahoo


Skype


Location


Interests

  1. I'd like to add some HTML to my Datapage to conditionally change the color of a report's background and text color based on the value of a calculated field. This field finds the number of days left until a project is due. I'd like to change the text color of this field to red and the background to yellow if it is past due (if the days left are negative). I know there are a couple of other pre-existing threads on this topic but for some reason I am having no luck. I pasted these in the source of my header but they had no effect. Let me know if you see anything wrong with my formulas: //for the background <a id="visi[@calcfield:1#]"> <script> var isi = document.getElementById("visi[@calcfield:1#]"); if(isi < 0){ isi.parentNode.parentNode.style.backgroundColor = 'red'; } else{ isi.parentNode.parentNode.style.backgroundColor = '#NoColor'; } </script></a> //for the text <div id="mydiv[@calcfield:1#]"> </div> <SCRIPT LANGUAGE="JavaScript"> if ("[@calcfield:1#]" < "0"){ document.getElementById("mydiv[@calcfield:1#]").innerHTML ="<span style='color:red;'> [@calcfield:1#] </span>"; } </SCRIPT>
  2. I can color the background on input fields, but not having luck on calculated fields. Also want the amount in bold.
  3. Hello, I would like to create a calculated field in tabular report datapage that displays a column in related table as a concatenated string. For Example, many of my apps use the tblPlants as a data source. This is a table of plant species that has a one-to-many relationship with many other tables. I would like to present a field in the report that lists the the botanical gardens for each plant is found in from the tblBG as a string. SELECT STRING_AGG(tblBG.Garden,",") FROM tblBG WHERE tblBG.PlantID = [@field:PlantID]; I get an error that say there is a syntax error near "(", which I take to meant hat the STRING_AGG function does not exist. Is there another function I could use to accomplish this?
  4. Hi, I'm have a calculated field that gets values from a View by the earliest date. It puts together a string (for html view) with 3 fields (date, project, and title) of the record so it can be displayed in an html block. It looks like this: CONVERT(VARCHAR(40),(SELECT TOP 1 DueDate FROM _V_Client_Portal_Calendar_Notify Where PortalID='[@authfield:PortalID]' ORDER BY DueDate ASC)) + '<br />' + (SELECT TOP 1 Project_Name FROM _V_Client_Portal_Calendar_Notify Where PortalID='[@authfield:PortalID]' ORDER BY DueDate ASC) + '<br /><i>' + (SELECT TOP 1 Title FROM _V_Client_Portal_Calendar_Notify Where PortalID='[@authfield:PortalID]' ORDER BY DueDate ASC) The issue is I need to then have another calculated field that gets the 2nd 'top' record, and another for the 3rd and 4th. How do you change this calculation to pull the 2nd record instead of the first? The result is I what to be able to pull the next 4 events in a calendar table, one in each calculated field, so they can be displayed as notifications.
  5. Hello, I've been trying to find a solution to this for awhile. Does anyone know how to limit/round the decimal places on a field and calculated field, over-riding whatever the setting is in the Localization. I need to do this because in some places I need the localization to show 3 decimal points for percentages and sometimes 0 decimal places (rounding whatever the value is). This is because I have multiple fields on the same datapage that use percentages for display and one needs 3 decimal places and the other needs 0. It makes it sloppy looking to always have .000 after the values for the field and/or calculated field that should normally so none. Thanks for any help.
  6. Just wanted to share a workflow on how to create a an editable formula field. This will allow you to calculate the value for a field based on other fields (Formula) or manually input the desired value. 1. Create a virtual field that will contain your formula. 2. Add a header and footer in your DataPage and disable the HTML editor on the footer. 3. In the footer put the following code: <script> document.querySelector("input[id*='VIRTUAL_FIELD_ID']").onchange = function() {myFunction()}; function myFunction() { var virtual_val = document.querySelector("input[id*='VIRTUAL_FIELD_ID']").value; document.querySelector("input[id*='FIELD_ID']").value = virtual_val; } </script> note: The field that is going to be used for the "field_id" will be the actual field that will store the calculation.
  7. Hi everyone, Does anyone know how to render a calculated field as HTML? I tried outputting HTML tags inside calculated fields, but they display as plain text. Thanks in advance. -dspolyglot
  8. I am trying to get the count from a table and applying record level security, but in the where clause, when I am comparing it with my auth field, it is saying "Invalid Query" For instance, my query: ISNULL((SELECT COUNT(DISTINCT [@field:PropertyKeyId]) FROM UI_FactTrxn_1 WHERE [@field:InvestorUserId] = [@authfield:Users_UserId]),0) I am getting Invalid error for this. But when I am trying to pass the string in place of authfield, it is a valid one! Can anyone please help me on this?
  9. Hi there, I have a formula that is working fine in most instances, but it falls down every once in a while. I think I've got it figured out and then it falls down again! This is my code IsNull((SELECT sum(IsNull([@field:Optimiser_RatingX],0)+IsNull([@field:QA_Tester_RatingX],0)) FROM Card_comments_and_updates WHERE User_ID=[@field:Analyst_IDX])/((SELECT COUNT(IsNull([@field:Optimiser_RatingX],0)) FROM Card_comments_and_updates WHERE IsNull([@field:Optimiser_RatingX],0) >0 AND User_ID=[@field:Analyst_IDX])+(SELECT COUNT(IsNull([@field:QA_Tester_RatingX],0)) FROM Card_comments_and_updates WHERE IsNull([@field:QA_Tester_RatingX],0) >0 AND User_ID=[@field:Analyst_IDX])),0) I want it to display zero if it can't calculate anything! Basically my datapage displays all my users along with an average of all the star ratings they have. The calculated field looks in a different table for every instance where the user ID in this table is listed in the Analyst column. Then it checks the 2 different fields where ratings are given (QA Tester Rating and Optimiser rating) for values more than 0. Adds them together and then divides them by the count, thereby giving the average. For the most part it works fine ... EXCEPT where there are fields where either the QA Tester Rating or Optimiser Rating are zero. Help! Many thanks Nikki
  10. Hi there, I have a tabular report datapage, that I am using to display calculations from my table. I want to show week number, and what has happened during that week. So far I have 2 columns other than week number, number of cards updated, and total number of updates. The calculations I am using are working fine, but it's showing each number as a separate row. So if the calculation for week 6 is 7 updates, it shows 7 rows. See attached screenshot. Below is my code. Anyone know how I only show each line once (so there's only 1 row for each week number) Number of cards updated SELECT COUNT (DISTINCT [@field:Card_ID]) FROM Card_comments_and_updates WHERE Week=target.[@field:Week] Total number of updates SELECT COUNT([@field:Card_ID]) FROM Card_comments_and_updates WHERE Week=target.[@field:Week]
  11. I want a calculated field formula that can return the date in MM/DD/YYYY format. How can I get this?
  12. I have a calculated field in my datapage to find the biggest "Clean_Serial_Number" under a particular Job_ID. There are many serial numbers under each job so I want it to find the max serial number under JUST that job. Right now, this field is just displaying the max "Clean_Serial_Number" from all the data, not just from the Job_ID. SELECT MAX(Clean_Serial_Number) FROM tbl_ggl_job_lines WHERE Job_ID = [@field:Job_ID] What am I doing wrong?
  13. I inserted a "Calculated Field" as a "Datapage Element." I used the calculated value but do not want the calculated value to show up on the "Details Page." How do I hide a Calculated Field from showing up on the "Details Page?" I need to keep it as a Datapage Element; however, I do not need the value displayed in the Details Page. Thanks, Thor
  14. Datapage type: Tabular report Objective: To show a red flag whenever two calculated fields did not produce the same results. Question: Is it possible to embed a graphic in calcualted field? I issued the following string that when checked for validity gives out a "valid" confirmation. I was very happy. But then when I checked the embedded code on html, it gives "Error in formula". Below is the code: CASE WHEN [@calcfield:3]=[@field:Grade] THEN '' ELSE <img src="https://mysource.com/images/redflag.jpg"> END All help is appreciated as usual. Best, Elena
  15. BLUF: does anyone have any suggestions on how to make a submission form's rules engine read the values from a virtual calculated field? i am using virtual calculated fields in a submission form to query five boolean variables in another table which specifies which of the five fields in the form should be required (this is customizable by the user through a separate form). the queries successfully execute and i am getting expected results (i.e. 'Yes' and 'No' for each of the five variables), which are based on the user's selection of a profile in a dropdown in the same form (e.g. profile a, profile b, profile c, which, again, they configure through another form). the queries are dynamic...they correctly recalculate as the user changes their 'profile' selection. i've attached a screenshot of the interface. i need to use these virtual calculated fields ('Yes' and 'No') values in the form's rules so that i can specify which of the fields are mandatory based on the selected profile. though the rules engine seems to be able to distinguish between 'is blank' and 'is not blank' on the virtual fields, it seems incapable of reading the values. that is, i have tried "virutal field 1 is equal to Yes" (or 'yes' or 'true' or 1)....and nothing works. does anyone have any suggestions on how to make the rules engine read the values from a virtual calculated field? p.s. for the form submission, i am using a view which joins the profile table with the test entries table. however, since only the test entries are editable in the view, i don't have access to the profile values (even though they are duly joined through the view) and therefore can't use them directly in the rule. this is why i have had to resort to using virtual calculated fields with sql queries.
  16. I'm trying to trigger a calculated field contingent on a select2 field or a hidden calculated field and I can't make it work. This is what I have: Field1(Cascading Dropdown Field for value: Field_ID) (converted into a select2 element using $('select[name="InsertRecordField1"]').select2();) VirtualField1 (Calculated Field) (Using the following sql SELECT Field_Name FROM Table WHERE [@field:Field1] = Field_ID) The SQL doesn't notice the changes made to Field1 nor its initial value on page load. I tried using JavaScript and SQL to give Field1's value to a another hidden Virtual Field and trigger the SQL with the following code: <script> document.getElementById('caspioNote').onmousemove = function() {myFunction();}; function myFunction() { var i = document.getElementsByName('InsertRecordField1')[0].value; document.getElementsByName('cbParamVirtual2')[0].value = i; } </script> ------ SQL for VirtualField1: SELECT Field_Name FROM Table WHERE [@cbParamVirtual2] = Field_ID The JavaScript works fine but the SQL does not seem to notice the changes in VirtualField2 This happens to other cascading fields too when I use VirtualField2 as the Parent Field. How could I archive this? Thanks in advance
  17. Hello, Is there a way to refresh a calculated field when a button is clicked? I have a field set to 'Calculated Field' in a submission form that references a couple other fields that themselves are updated with a button's js function. When you don't manually (type in) update a field then the calculated field won't show any changes. So when my button's function runs and Field1 gets a timestamp, the calculated field that uses Field1 doesn't refresh. It does refresh if I type in the time/date to Field1. I'm need to show the refreshed value in the calculated field before it is submitted. Any help would be appreciated!
  18. Does anyone know how to use 'contains' in a calculated field to see if the field contains a certain value, instead of using = to equal it. I have a tale with records that have a field with values like 524_789B, 524_788B, 524_794B, 524_791B, 524_1047B. And an authenticated field value might be 524_794B. I want to count the number of records that contain 524_794B. So in a calculated field I need something like below: SELECT COUNT (ItemID) FROM _V_Items Where Assigned_To CONTAINS '[@authfield:Users_CID_StaffID]' What is the syntax for 'contains'?
  19. Hello All, I would like to COUNT the values between a certain time frame regardless of date... for this example lets say 10AM and 4PM or 10:00 and 16:00. Please consider: Item1: 01/07/15 11:00:00 Item2: 01/04/15 13:00:00 Item3: 01/03/15 07:00:00 Item4: 01/06/15 17:00:00 Item5: 01/03/15 09:00:00 Item6: 01/07/15 15:00:00 Desired results: 3 I can pull the hour from the date, but I can't figure out how to filter by hour or count values in a range. Any ideas? Thanks
  20. Hi everyone, I would like to implement XIRR function from Excel in Caspio. Can somebody give me a direction on how to achieve this? Thanks, vitalikssssss
  21. Is there a way to create a search filter for a calculated field?
  22. I need to reference a calculated field's value for use in an If/Then function in js. The calculated field uses a SELECT to calculate a View's total records, which is either null or with some records in the result. If the calculated field has a null value I need something to happen vs if it's not null. Here's the code: <script> var v_itemsid = parseFloat(document.getElementById("EditRecordcalcfield18").value); if(!isNaN(v_itemsid)) { document.getElementById('section1').style.display = "block"; document.getElementById('section2').style.display = "none"; } else { document.getElementById('section1').style.display = "none"; document.getElementById('section2').style.display = "block"; } </script> I've used this code before with a regular table field: how is the calculated field referenced where EditRecord is (EditRecordcalcfield18 obviously isn't right)? I don't know the syntax. Any help would be great- thanks in advance.
  23. Hello all; I am trying to log the time users are logged in, and I am unable to get any precision. I would like hours to be displayed with two decimal places of accurate precision, but Datediff rounds to the nearest unit of time. This (IMO) should be fairly easy to overcome by using a smaller unit of time, and dividing that large number by 60 or 3600 (for minute or second), but no luck. Using the following sessions let's look at what I want, what I've tried, and what I'm getting. SessionID = 1 | LoginDT 8-17-2014 09:00:00 | LogoutDT 8-17-2014 09:15:00 SessionID = 2 | LoginDT 8-17-2014 10:00:00 | LogoutDT 8-17-2014 10:40:00 SessionID = 3 | LoginDT 8-17-2014 11:00:00 | LogoutDT 8-17-2014 13:30:00 Desired Result: SessionID = 1 | Logged Hours 0.25 SessionID = 2 | Logged Hours 0.67 SessionID = 3 | Logged Hours 2.50 Datediff(hour,[@field:LoginDT],[@field:LogoutDT]) SessionID = 1 | Logged Hours 0.00 SessionID = 2 | Logged Hours 0.00 SessionID = 3 | Logged Hours 2.00 Datediff(minute,[@field:LoginDT],[@field:LogoutDT]) SessionID = 1 | Logged Hours 15.00 SessionID = 2 | Logged Hours 40.00 SessionID = 3 | Logged Hours 150.00 Datediff(minute,[@field:LoginDT],[@field:LogoutDT])/60 SessionID = 1 | Logged Hours 0.00 SessionID = 2 | Logged Hours 0.00 SessionID = 3 | Logged Hours 2.00 (Datediff(minute,[@field:LoginDT],[@field:LogoutDT]))/60 SessionID = 1 | Logged Hours 0.00 SessionID = 2 | Logged Hours 0.00 SessionID = 3 | Logged Hours 2.00 Round(Datediff(minute,[@field:LoginDT],[@field:LogoutDT])/60,2) SessionID = 1 | Logged Hours 0.00 SessionID = 2 | Logged Hours 0.00 SessionID = 3 | Logged Hours 2.00 Round((Datediff(minute,[@field:LoginDT],[@field:LogoutDT]))/60,2) SessionID = 1 | Logged Hours 0.00 SessionID = 2 | Logged Hours 0.00 SessionID = 3 | Logged Hours 2.00 Any ideas? Thanks!
  24. Hello, I have a Text field (64000) that is used to hold addresses with html markup. I need to use calculated fields to get each line's value for use in importing to another app that requires the address to be broken down to individual fields. For example, the value in the text field might be: Acme Building <br /> 22 Main Street <br /> Suite 33 <br /> Atlanta, GA 30308 I need it to take each line and put it in a calculated field: Calculated Field 1 = "Acme Building" Calculated Field 2 = "22 Main Street" Calculated Field 3 = "Suite 33" Calculated Field 4 = "Atlanta, GA 30308" There will always be a <br /> to break up the lines so I was thinking that might be used in the formula to delineate which lines are which. I have no idea of what the formulas would look like, though. Does anyone know how to do this? Many thanks!
  25. Following syntax worked as script for a calculated field in a previous report: label: Time Period (Start Date) [@field:EA_StartDate] + CASE WHEN LEN([@field:EA_EndDate]) > 1 THEN ' - ' + [@field:EA_EndDate] END Currently [@field:EA_StartDate] + ' - ' already generates "Invalid Formula" when verifying the script.
×
×
  • Create New...