cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Calling a Variable in Part of a Column Name Using LookUp

Hi all - 

I'm somewhat new to PowerApps and am trying to pass a variable in a column name in a LookUp function and am currently unable to figure out how to do so. I've searched these boards (perhaps I'm using the wrong search terms) but haven't seen this issue in the boards. Surely I'm not the only one with this issue?

My SP List has columns labeled 'January Week 1,' 'January Week 2,' 'January Week 3,' 'January Week 4,' 'January Week 5,' 'February Week 1,' 'February Week 2,' 'February Week 3,' 'February Week 4,' 'February Week 5,' ...and so on.

My var is SelectedMonth, and updates based on the user's selection.

 

I have a label that is successfully displaying 
          SelectedMonth & " Week 1"

 

However, I'm unable to pull the data from the SP list from that column. I currently have:
          LookUp('Hours Cross Charged', Name=User().FullName, 'January Week 1')

 

Anytime that I try to put a variable in the single quotes, under several different combinations I've tried, it gives me an error. 
What way can I tell PowerApps to retrieve the data from column 
          'SelectedMonth & " Week 1"'?

Any help is greatly appreciated!!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Calling a Variable in Part of a Column Name Using LookUp

@Anonymous 

Unfortunately you cannot dynamically reference a column in PowerApps like this.

 

SelectedMonth & " Week 1"'?

All you can do is use a SWITCH function instead

 

Switch(
    SelectedMonth,
    "January", 'January Week1', 
    "February", 'February Week 1',
    "March", 'March Week 1'
)

I know it is possible in many PRO programming languages but not here.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

3 REPLIES 3
Highlighted
Super User
Super User

Re: Calling a Variable in Part of a Column Name Using LookUp

@Anonymous 

Unfortunately you cannot dynamically reference a column in PowerApps like this.

 

SelectedMonth & " Week 1"'?

All you can do is use a SWITCH function instead

 

Switch(
    SelectedMonth,
    "January", 'January Week1', 
    "February", 'February Week 1',
    "March", 'March Week 1'
)

I know it is possible in many PRO programming languages but not here.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Highlighted
Anonymous
Not applicable

Re: Calling a Variable in Part of a Column Name Using LookUp

Thank you for the clarification! It seems that it would make things simpler if we could type functions with variables such as this. Perhaps one day in the future. Thanks again @mdevaney

Highlighted
Super User
Super User

Re: Calling a Variable in Part of a Column Name Using LookUp

@Anonymous 

I agree, custom functions would be very nice.  You can always go submit it as an Idea and see if it catches on.

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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