cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gorilla_8
Super User
Super User

Create an addcolumns comparing values from one column with the new column

I want to create an addcolumns comparing values from one column with the new column to perform a filter.

 

Example:

 

In my original table, I can a choice column with 3 values:

 

High
Low
Medium

 

And I created a collection from this table a new column replacing the values to:

 

1High
2Medium
3Low

 

So, I would like to add a new column with "AddColumns" in my table comparing where it has in the original table the value "High" in the new column by "1High" and in the "Low" column by "3Low" and in the third and last "Medium" by "2Medium".

 

This way I can make the filter correctly

 

My code so far:

 

ClearCollect(colChoiceColumnModified;Choices(MyOriginalList.ChoiceColumn));;

ClearCollect(colAllBase;MyOriginalList);;

UpdateIf(colChoiceColumnModified;Value="High";{Value: "1High"};Value="Medium";{Value: "2Medium"};Value="Low";{Value: "3Low"});;


// And here's where I can't do it

ClearCollect(colAll;colChoiceColumnModified;colAllBase);;
 ClearCollect(
    colAll;
    AddColumns(
        colAll;
        "newColumChoice";
        LookUp(
            colAll;
            ChoiceColumn.Value = "High";
            NewColumChoice
        )
    )
)
1 ACCEPTED SOLUTION

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi @Gorilla_8,

If you want to join two collections to make them one to one in the same row, you should make sure that both these two collections have the same data structure.

 

Please modify your formula as below:

ClearCollect(colChoiceColumnModified;Choices(MyOriginalList.ChoiceColumn));;

ClearCollect(colAllBase;MyOriginalList);;

UpdateIf(colChoiceColumnModified;Value="High";{Value: "1High"};Value="Medium";{Value: "2Medium"};Value="Low";{Value: "3Low"});;
// And here's where I can't do it
ClearCollect(
    colAll;
    AddColumns(
        colAllBase;
        "NewColumChoice";
        ""
    )
);;
UpdateIf(
    colAll;
    ChoiceColumn.Value = "High";
    {NewColumChoice: "1High"};
    ChoiceColumn.Value = "Medium";
    {NewColumChoice: "2Medium"};
    ChoiceColumn.Value = "Low";
    {NewColumChoice: "3Low"}
);;
Best Regards,
Qi

View solution in original post

1 REPLY 1
v-qiaqi-msft
Community Support
Community Support

Hi @Gorilla_8,

If you want to join two collections to make them one to one in the same row, you should make sure that both these two collections have the same data structure.

 

Please modify your formula as below:

ClearCollect(colChoiceColumnModified;Choices(MyOriginalList.ChoiceColumn));;

ClearCollect(colAllBase;MyOriginalList);;

UpdateIf(colChoiceColumnModified;Value="High";{Value: "1High"};Value="Medium";{Value: "2Medium"};Value="Low";{Value: "3Low"});;
// And here's where I can't do it
ClearCollect(
    colAll;
    AddColumns(
        colAllBase;
        "NewColumChoice";
        ""
    )
);;
UpdateIf(
    colAll;
    ChoiceColumn.Value = "High";
    {NewColumChoice: "1High"};
    ChoiceColumn.Value = "Medium";
    {NewColumChoice: "2Medium"};
    ChoiceColumn.Value = "Low";
    {NewColumChoice: "3Low"}
);;
Best Regards,
Qi

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (2,615)