cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Column exists, but is not found - RenameColumns() issue

Hello,

 

I have been trying to go around the referencing issue (when two columns in different tables are named the same) by using RenameColumns(), unfortunately in one of the functions this doesn't work and gives me an error - "The specified column 'test id' does not exist".

 

ForAll(
    TemplateGalleryList3_2.AllItems,
    Patch(
        list_of_all_tests,
        LookUp(
            RenameColumns(
            list_of_all_tests,
            "test id", /* column not found */
            "list_of_all_tests_test_id", 
            "test project id", /* column not found */
            "list_of_all_tests_test_project_id"
            ),
            list_of_all_tests_test_project_id = LoadProjectID && list_of_all_tests_test_id = 'test id' /* 'test id' here comes from the TemplateGalleryList3_2 */
            ),
            {
                Result_1_value: TextInput2.Text,
                Result_2_value: TextInput2_1.Text
            }
    )
);

 

Additionally, if I rename columns that are to be changed to some other name that exists in the table but is without a space character, it then shows that newly renamed columns can not be recognised (in the conditional part of LookUp() ).

I am 100% sure that columns with such names ("test id" and "test project id") exist in the table of interest.q table.PNG 

 

Any ideas why this might be happening?
Cheers!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@gabibalaban 

Worth a shot 😉

However, it appears from the formula that a collision of the rename to the list is the culprit.  

@DrMantas if that is not so, then another consideration is the following:

ForAll(
    TemplateGalleryList3_2.AllItems As gal,
    Patch(
        list_of_all_tests,
        LookUp(list_of_all_tests,
            test_project_id = LoadProjectID && test_id = gal.'test id'
        ),
        {
            Result_1_value: TextInput2.Text,
            Result_2_value: TextInput2_1.Text
        }
    )
);
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

6 REPLIES 6
Super User III
Super User III

@DrMantas 

Yes, this is completely because you are assigning the results of the Renamed columns list to the same list (list_of_all_tests).

 

When you do that, PowerApps will take the signature of the inner function (RenameColumns) and assign to the outer list (list_of_all_tests).  However this causes confusion because now list_of_all_tests no longer has the test id column (as it's been renamed). 

 

So, moral of the story...you cannot assign a table array (which is what RenameColumns returns) to the same table array.  It will, in the case of RenameColumns give an error the the column does not exist, and in the case of AddColumns, that the column already exists.

 

If you can explain a little more about what you are trying to accomplish, I believe what you are doing can be quite simplified.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Super User II
Super User II

Hi @DrMantas ,

 

I'll try my luck asking you to replace spaces with "_x0020_":

 

ForAll(
    TemplateGalleryList3_2.AllItems,
    Patch(
        list_of_all_tests,
        LookUp(
            RenameColumns(
            list_of_all_tests,
            "test_x0020_id", /* column not found */
            "list_of_all_tests_test_id", 
            "test_x0020_project_x0020_id", /* column not found */
            "list_of_all_tests_test_project_id"
            ),
            list_of_all_tests_test_project_id = LoadProjectID && list_of_all_tests_test_id = 'test id' /* 'test id' here comes from the TemplateGalleryList3_2 */
            ),
            {
                Result_1_value: TextInput2.Text,
                Result_2_value: TextInput2_1.Text
            }
    )
);

 

I think this worth a try ... 😊.

@gabibalaban 

Worth a shot 😉

However, it appears from the formula that a collision of the rename to the list is the culprit.  

@DrMantas if that is not so, then another consideration is the following:

ForAll(
    TemplateGalleryList3_2.AllItems As gal,
    Patch(
        list_of_all_tests,
        LookUp(list_of_all_tests,
            test_project_id = LoadProjectID && test_id = gal.'test id'
        ),
        {
            Result_1_value: TextInput2.Text,
            Result_2_value: TextInput2_1.Text
        }
    )
);
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Frequent Visitor

Thank you for your suggestions
@gabibalaban  yes I have tried this, but unfortunately it didn't change anything

@RandyHayes  it is quite interesting, as it worked in a few other functions (forum topic Value reference issue in ForAll() ), thus I am not sure why it fails this time. What I am trying to achieve is actually very simple - write values to the table. 
expla.png

As you can see from a picture, gallery prints a list with tests (some tests like the first one might have two results), once a user enters the results a button "save" should be pressed to update the table. The code that you saw above was from the latter button executed upon on click. In this case the table that look up is performed on, and the table that result is written in is the same.

I tried your suggestion using As and while it didn't fix it instantly, with a few tweaks I managed get it working. The code right now: 

 

ForAll(
    TemplateGalleryList3_2.AllItems As gal,
    Patch(list_of_all_tests,
        LookUp(list_of_all_tests,
            'test project id' = LoadProjectID && list_of_all_tests[@'test id'] = gal.'test id'
            ),
            {
                Result_1_value: gal.TextInput2.Text, //without gal it captured only the first text field
                Result_2_value: gal.TextInput2_1.Text
            }
    )
);

 

The last issue - once this code reads and writes values to the table, the text in TextInput disappears (gradually down the gallery one after another which shows that it happens once it was read, this actually nicely demonstrates that Writing information to excel table is very slow). Any thoughts on this?

If you think that I am overcomplicating simple writing to table procedure, please do suggest something else 🙂 

@DrMantas 

So if you are using Excel, there is not much to "ID" it off of.  Meaning that you can't just do a straight update of the table based on the Gallery.

If your values are disappearing as the formula executes then the first place to look would be how you are getting the values into the textboxes to start with.  And, is list_of_all_tests a collection or the name of your DataSource?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Frequent Visitor

Sorry @RandyHayes , had a very busy week. Yes your solution did work, thanks very much. Regarding your idea about how I 'get data into textboxes', I managed to sort issue by setting the default value to be taken from the table. This solves the problem of those values disappearing once they are accessed using TextInput.Text

 

Cheers!

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (2,968)