cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BrianHFASPS
Responsive Resident
Responsive Resident

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
Anonymous
Not applicable

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

 

@Anonymous

View solution in original post

1 REPLY 1
Anonymous
Not applicable

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

 

@Anonymous

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (28,844)