cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
BrianHFASPS 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
TopShelf-MSFT 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
TopShelf-MSFT 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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (7,240)