cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

Column Name variable?

I found this https://powerusers.microsoft.com/t5/PowerApps-Ideas/Patch-Referance-a-column-name-via-a-variable/idi... and it might be the only option but I wanted to check. I have a table with 3 columns per day for 5 days a week. Depending on the change it needs to be made to one of those 15 columns. The only way I have found to do it is with 10 or 15 If statements. If I could just set a variable and use that as reference for column name I could store it with the object that is going into table. I will share one of my if statements that I must do multiple times in my app to see if anyone has suggestion on better way. It is possible I made some mistakes in DB design but I can't think of another way to do it.

    If(
        'Class Name Input'.Selected.'Day of Week' = "Monday" && 'Class Name Input'.Selected.'Time Slot' = "3:30-4:30",
        Patch(
            '[dbo].[Activity Signup]',
            First(
                Filter(
                    '[dbo].[Activity Signup]',
                    DailyActUID = 'User ID',
                    'Date End String' = Text(
                        'Class End Date'.SelectedDate,
                        "[$-en-US]yyyy-mm-dd"
                    )
                )
            ),
            {MondaySlotOne: 'Class Name Input'.Selected.ActivityID}
        ),
        'Class Name Input'.Selected.'Day of Week' = "Monday" && 'Class Name Input'.Selected.'Time Slot' = "3:30-5:00",
        Patch(
            '[dbo].[Activity Signup]',
            First(
                Filter(
                    '[dbo].[Activity Signup]',
                    DailyActUID = 'User ID',
                    'Date End String' = Text(
                        'Class End Date'.SelectedDate,
                        "[$-en-US]yyyy-mm-dd"
                    )
                )
            ),
            {
                MondaySlotOne: 'Class Name Input'.Selected.ActivityID,
                MondaySlotTwo: 'Class Name Input'.Selected.ActivityID
            }
        ),
        'Class Name Input'.Selected.'Day of Week' = "Tuesday" && 'Class Name Input'.Selected.'Time Slot' = "3:30-4:30",
        Patch(
            '[dbo].[Activity Signup]',
            First(
                Filter(
                    '[dbo].[Activity Signup]',
                    DailyActUID = 'User ID',
                    'Date End String' = Text(
                        'Class End Date'.SelectedDate,
                        "[$-en-US]yyyy-mm-dd"
                    )
                )
            ),
            {TuesdaySlotOne: 'Class Name Input'.Selected.ActivityID}
        ),
        'Class Name Input'.Selected.'Day of Week' = "Tuesday" && 'Class Name Input'.Selected.'Time Slot' = "3:30-5:00",
        Patch(
            '[dbo].[Activity Signup]',
            First(
                Filter(
                    '[dbo].[Activity Signup]',
                    DailyActUID = 'User ID',
                    'Date End String' = Text(
                        'Class End Date'.SelectedDate,
                        "[$-en-US]yyyy-mm-dd"
                    )
                )
            ),
            {
                TuesdaySlotOne: 'Class Name Input'.Selected.ActivityID,
                TuesdaySlotTwo: 'Class Name Input'.Selected.ActivityID
            }
        ),
        'Class Name Input'.Selected.'Day of Week' = "Wednesday" && 'Class Name Input'.Selected.'Time Slot' = "3:30-4:30",
        Patch(
            '[dbo].[Activity Signup]',
            First(
                Filter(
                    '[dbo].[Activity Signup]',
                    DailyActUID = 'User ID',
                    'Date End String' = Text(
                        'Class End Date'.SelectedDate,
                        "[$-en-US]yyyy-mm-dd"
                    )
                )
            ),
            {WednesdaySlotOne: 'Class Name Input'.Selected.ActivityID}
        ),
        'Class Name Input'.Selected.'Day of Week' = "Wednesday" && 'Class Name Input'.Selected.'Time Slot' = "3:30-5:00",
        Patch(
            '[dbo].[Activity Signup]',
            First(
                Filter(
                    '[dbo].[Activity Signup]',
                    DailyActUID = 'User ID',
                    'Date End String' = Text(
                        'Class End Date'.SelectedDate,
                        "[$-en-US]yyyy-mm-dd"
                    )
                )
            ),
            {
                WednesdaySlotOne: 'Class Name Input'.Selected.ActivityID,
                WednesdaySlotTwo: 'Class Name Input'.Selected.ActivityID
            }
        ),
        'Class Name Input'.Selected.'Day of Week' = "Thursday" && 'Class Name Input'.Selected.'Time Slot' = "3:30-4:30",
        Patch(
            '[dbo].[Activity Signup]',
            First(
                Filter(
                    '[dbo].[Activity Signup]',
                    DailyActUID = 'User ID',
                    'Date End String' = Text(
                        'Class End Date'.SelectedDate,
                        "[$-en-US]yyyy-mm-dd"
                    )
                )
            ),
            {ThursdaySlotOne: 'Class Name Input'.Selected.ActivityID}
        ),
        'Class Name Input'.Selected.'Day of Week' = "Thursday" && 'Class Name Input'.Selected.'Time Slot' = "3:30-5:00",
        Patch(
            '[dbo].[Activity Signup]',
            First(
                Filter(
                    '[dbo].[Activity Signup]',
                    DailyActUID = 'User ID',
                    'Date End String' = Text(
                        'Class End Date'.SelectedDate,
                        "[$-en-US]yyyy-mm-dd"
                    )
                )
            ),
            {
                ThursdaySlotOne: 'Class Name Input'.Selected.ActivityID,
                ThursdaySlotTwo: 'Class Name Input'.Selected.ActivityID
            }
        ),
        'Class Name Input'.Selected.'Day of Week' = "Friday" && 'Class Name Input'.Selected.'Time Slot' = "3:30-4:30",
        Patch(
            '[dbo].[Activity Signup]',
            First(
                Filter(
                    '[dbo].[Activity Signup]',
                    DailyActUID = 'User ID',
                    'Date End String' = Text(
                        'Class End Date'.SelectedDate,
                        "[$-en-US]yyyy-mm-dd"
                    )
                )
            ),
            {FridaySlotOne: 'Class Name Input'.Selected.ActivityID}
        ),
        'Class Name Input'.Selected.'Day of Week' = "Friday" && 'Class Name Input'.Selected.'Time Slot' = "3:30-5:00",
        Patch(
            '[dbo].[Activity Signup]',
            First(
                Filter(
                    '[dbo].[Activity Signup]',
                    DailyActUID = 'User ID',
                    'Date End String' = Text(
                        'Class End Date'.SelectedDate,
                        "[$-en-US]yyyy-mm-dd"
                    )
                )
            ),
            {
                FridaySlotOne: 'Class Name Input'.Selected.ActivityID,
                FridaySlotTwo: 'Class Name Input'.Selected.ActivityID
            }
        )
    )

I make some variation of this depending on what I am doing to table.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Column Name variable?

Hi @BrianHFASPS thank you for posting this thread. I would monitor the proposed new idea you linked to and I will also add in @CWesener in case there is an update he can share

 

@TopShelf-MSFT

View solution in original post

1 REPLY 1
Highlighted
Community Champion
Community Champion

Re: Column Name variable?

Hi @BrianHFASPS thank you for posting this thread. I would monitor the proposed new idea you linked to and I will also add in @CWesener in case there is an update he can share

 

@TopShelf-MSFT

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (8,657)