cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Becca51178
Helper II
Helper II

Need Help with Add Columns Formula

 I need help with a formula. If anyone has a better way to do this then that would be awesome.

 

ClearCollect(ReviewList, 
AddColumns(Filter(FSDetailSupport_, Review_Status.Value="Sent to Reviewer3" || Review_Status.Value="Sent to Reviewer2" || Review_Status.Value="Sent to Reviewer1"),
"CurrentReviewer",
If(Review_Status.Value="Sent to Reviewer1",LookUp(FSDetailSupport_,ID=ID,Reviewer_1.DisplayName),
If(Review_Status.Value="Sent to Reviewer2",LookUp(FSDetailSupport_,ID=ID,Reviewer_2.DisplayName),
If(Review_Status.Value="Sent to Reviewer3",LookUp(FSDetailSupport_,ID=ID,Reviewer_3.DisplayName)))))); 

 

I currently am using the above collection formula to add a column called "Current User" that looks up the name of the user based on the value in the Review_Status Column. For whatever reason it will not pull in the user for column when the review status is "Sent to Reviewer3". I have tried everything. It's not formatting. I don't know how to fix it, but I really need it to do this. 

 

Is there a better formula I could use?  

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Becca51178 :

I guess this condition "ID=ID" may cause ambiguity.Please Try:

 

ClearCollect(ReviewList,
            AddColumns(
                 RenameColumns(Filter(FSDetailSupport_,Review_Status.Value="Sent to Reviewer3" || Review_Status.Value="Sent to Reviewer2" || Review_Status.Value="Sent to Reviewer1"),"ID","IDD"),
                 "CurrentReviewer",
                 If(Review_Status.Value="Sent to Reviewer1",
                    LookUp(FSDetailSupport_,ID=IDD,Reviewer_1.DisplayName),
                    If(Review_Status.Value="Sent to Reviewer2",
                       LookUp(FSDetailSupport_,ID=IDD,Reviewer_2.DisplayName),
                       If(Review_Status.Value="Sent to Reviewer3",
                       LookUp(FSDetailSupport_,ID=IDD,Reviewer_3.DisplayName))))));

 or

ClearCollect(ReviewList,
            AddColumns(
                 RenameColumns(Filter(FSDetailSupport_,Review_Status.Value="Sent to Reviewer3" || Review_Status.Value="Sent to Reviewer2" || Review_Status.Value="Sent to Reviewer1"),"ID","IDD"),
                 "CurrentReviewer",
                 If(Review_Status.Value="Sent to Reviewer1",
                    Reviewer_1.DisplayName,
                    If(Review_Status.Value="Sent to Reviewer2",
                       Reviewer_2.DisplayName,
                       If(Review_Status.Value="Sent to Reviewer3",
                       Reviewer_3.DisplayName))))); 

or

ClearCollect(ReviewList,
            AddColumns(
                 RenameColumns(Filter(FSDetailSupport_,Review_Status.Value="Sent to Reviewer3" || Review_Status.Value="Sent to Reviewer2" || Review_Status.Value="Sent to Reviewer1"),"ID","IDD"),
                 "CurrentReviewer",
                 Switch(Review_Status.Value,
                        "Sent to Reviewer1",
                        Reviewer_1.DisplayName,
                        "Sent to Reviewer2",
                        Reviewer_2.DisplayName,
                        "Sent to Reviewer3",
                        Reviewer_3.DisplayName))); 

If you still have any question,please don't hesitate to let me know.

Best Regards,

Bof

View solution in original post

5 REPLIES 5
v-bofeng-msft
Community Support
Community Support

Hi @Becca51178 :

I guess this condition "ID=ID" may cause ambiguity.Please Try:

 

ClearCollect(ReviewList,
            AddColumns(
                 RenameColumns(Filter(FSDetailSupport_,Review_Status.Value="Sent to Reviewer3" || Review_Status.Value="Sent to Reviewer2" || Review_Status.Value="Sent to Reviewer1"),"ID","IDD"),
                 "CurrentReviewer",
                 If(Review_Status.Value="Sent to Reviewer1",
                    LookUp(FSDetailSupport_,ID=IDD,Reviewer_1.DisplayName),
                    If(Review_Status.Value="Sent to Reviewer2",
                       LookUp(FSDetailSupport_,ID=IDD,Reviewer_2.DisplayName),
                       If(Review_Status.Value="Sent to Reviewer3",
                       LookUp(FSDetailSupport_,ID=IDD,Reviewer_3.DisplayName))))));

 or

ClearCollect(ReviewList,
            AddColumns(
                 RenameColumns(Filter(FSDetailSupport_,Review_Status.Value="Sent to Reviewer3" || Review_Status.Value="Sent to Reviewer2" || Review_Status.Value="Sent to Reviewer1"),"ID","IDD"),
                 "CurrentReviewer",
                 If(Review_Status.Value="Sent to Reviewer1",
                    Reviewer_1.DisplayName,
                    If(Review_Status.Value="Sent to Reviewer2",
                       Reviewer_2.DisplayName,
                       If(Review_Status.Value="Sent to Reviewer3",
                       Reviewer_3.DisplayName))))); 

or

ClearCollect(ReviewList,
            AddColumns(
                 RenameColumns(Filter(FSDetailSupport_,Review_Status.Value="Sent to Reviewer3" || Review_Status.Value="Sent to Reviewer2" || Review_Status.Value="Sent to Reviewer1"),"ID","IDD"),
                 "CurrentReviewer",
                 Switch(Review_Status.Value,
                        "Sent to Reviewer1",
                        Reviewer_1.DisplayName,
                        "Sent to Reviewer2",
                        Reviewer_2.DisplayName,
                        "Sent to Reviewer3",
                        Reviewer_3.DisplayName))); 

If you still have any question,please don't hesitate to let me know.

Best Regards,

Bof

Hi @Becca51178 ,

Just for something different - you might try the new As statement to cure the ambiguity. I have also done a With() and a Switch() to condense the code a bit.

ClearCollect(
   ReviewList, 
   AddColumns(
      Filter(
         FSDetailSupport_, 
         Review_Status.Value="Sent to Reviewer3" || 
         Review_Status.Value="Sent to Reviewer2" || 
         Review_Status.Value="Sent to Reviewer1"
      ) As vReview,
      "CurrentReviewer",
      With(
         {
            vName:
            LookUp(
               FSDetailSupport_,
               ID=vReview.ID
            )
         },
         Switch(
            Review_Status.Value,
            "Sent to Reviewer1",
            vName.Reviewer_1.DisplayName,
            "Sent to Reviewer2",
            vName.Reviewer_2.DisplayName,
            "Sent to Reviewer3",
            vName.Reviewer_3.DisplayName
         )
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

I really like this code but its throwing an error on the Switch part

Becca51178_0-1595944816402.png

 

Thanks! These both worked great!

Thanks @Becca51178 ,

You do have the option (up to you entirely) of accepting more than one solution, especially if they are helpful in the future for others.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,430)