Jump to content
  • 0

Having a calculated field in a data page display multiple results in one cell


KenWi

Question

Is there any way to have a calculated field in a data page display multiple return values from a select?

I have this

image.png.3fa330f661cda884f3686360227c38b4.png

But where that query should return 5 items it is only displaying the first one, Can I concatenate and iterate in some fashion? I was expecting the entire result set to appear.

 

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0
15 hours ago, PotatoMato said:

Hi @KenWi, you can use XML path to return multiple values that meet the condition. For example:

STUFF((SELECT field_name FROM table_name WHERE field = '1' FOR XML PATH ('')), 1, 1, '')

 

That seems to be getting me closer, as it will stuff a big block of XML in the cell. However using the SQL

Select DISTINCT Preceptor_Name_FullName from _v_M3_Placement_View where 
((Placement_Placement_ID = '[@field:Placement_Placement_ID]' AND Preceptor_Join_Placement_IsPrimary = 0 AND Placement_WeekNumber = '[@field:Placement_WeekNumber]') )

causes an issue as soon as I add FOR XML PATH (''), because at that point the system seems to lose any concept of [@field:Placement_Placement_ID].

Any experience on how to keep the variables I need to reference for the query? Possibly defining some intermediate variables?

Link to comment
Share on other sites

  • 0
7 hours ago, PotatoMato said:

What do you mean by "lose any concept of [@field:Placement_Placement_ID]"?

The XML returned is effectively the same as if the query was.

Select DISTINCT Preceptor_Name_FullName from _v_M3_Placement_View where 
(Preceptor_Join_Placement_IsPrimary = 0)

The 

Placement_Placement_ID = '[@field:Placement_Placement_ID] and

Placement_WeekNumber = '[@field:Placement_WeekNumber] 

seem to be being ignored, or evaluating against every possible value for the fields.

Removing FOR XML PATH ('') will result in the table displaying the proper number of Rows, but every row is individual and contains the first element of the expected result set.

Link to comment
Share on other sites

  • 0

Hello @KenWi,

Please test this formula:

STUFF((SELECT DISTINCT  ', ' + (Preceptor_Name_FullName) 
       FROM _v_M3_Placement_View
       WHERE Placement_Placement_ID = target.[@field:Placement_Placement_ID]
       AND Preceptor_Join_Placement_IsPrimary = 0 
       AND Placement_WeekNumber = target.[@field:Placement_WeekNumber]
  FOR XML PATH ('')), 1, 1, '')

If it doesn`t work, I think it is better to contact Caspio support since it is easier to troubleshoot the formula when there is access to data.

Link to comment
Share on other sites

  • 0
On 9/26/2024 at 4:35 AM, CoopperBackpack said:

Hello @KenWi,

Please test this formula:

STUFF((SELECT DISTINCT  ', ' + (Preceptor_Name_FullName) 
       FROM _v_M3_Placement_View
       WHERE Placement_Placement_ID = target.[@field:Placement_Placement_ID]
       AND Preceptor_Join_Placement_IsPrimary = 0 
       AND Placement_WeekNumber = target.[@field:Placement_WeekNumber]
  FOR XML PATH ('')), 1, 1, '')

If it doesn`t work, I think it is better to contact Caspio support since it is easier to troubleshoot the formula when there is access to data.

Thank you again, that worked perfectly and I would have never have thought that I needed to isolate the field using ()s. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...