cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BrianHFASPS
Level 8

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
TopShelf-MSFT
Level 10

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
TopShelf-MSFT
Level 10

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
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,331)