Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

field converted to a table

I am trying to convert a field (Title) to a table  I can get the first item but then it rejects?

What am I missing?

[FacContacts]:
LIB CONNECT TO [pharmoresql production (pharmore_rwinkel)];
LOAD [ConID],
  [Title],
  [Notes];
SQL SELECT  "ConID",
   "Title",
   "Notes"
FROM "Fac"."dbo"."FacContacts";

FinalTable1:

LOAD Distinct FacID

Resident FacContacts;

For i = 1 to FieldValueCount('Title')

  LET vField1 = FieldValue('Title', $(i));

  Left Join (FinalTable1)

   LOAD FacID,
             ['Title'] as [$(vField1)]
   Resident FacContacts

   Where ['Title'] = '$(vField1)';

NEXT

13 Replies
Not applicable
Author

Its filling in the field heading instead of the actual data?

sunny_talwar

I wish you saw my earlier response carefully and you would not have needed to go through all this trouble . Try this:

FinalTableA:

  LOAD Distinct FacID
  Resident FacContacts;
  For i = 1 to FieldValueCount('Title')
    LET vField1 = FieldValue('Title', $(i));

    Left Join (FinalTableA)

      LOAD FacID,
                Notes as [$(vField1)]
      Resident FacContacts

      Where [Title] = '$(vField1)';

NEXT

Please note that I have changed Title to Notes and also used the single quotes within my FieldValueCount() and FieldValue() functions.

HTH

Best,
Sunny

Not applicable
Author

I did try it that way and got this.  so then I tried a few variations trying to see what works and what don't.

I always copy and paste you give me because I know this is extremely sensitive and can be done in multiple ways. 

sunny_talwar

I think what we have is going in the right direction, we might just need to figure our if Notes field have any value in it. Have you checked the output of this table?

[FacContacts]:

LIB CONNECT TO [pharmoresql production (pharmore_rwinkel)];

LOAD [ConID],

[FacID],

[Title],

  [Notes];

SQL SELECT  "ConID",

  "FacID",

  "Title",

  "Notes"

FROM "Fac"."dbo"."FacContacts";

If you run this and create a table object with ConID, FacID and Title and Notes as dimension, what do you see?