web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Lookup Function return...
Power Apps
Answered

Lookup Function return Value based on what month it is

(0) ShareShare
ReportReport
Posted on by

I have a Table in Excel that is being used as Static Data Source and made a basic App. i want one of the Label Controls i added to show me a value on the table based on what month it is. I included a screen shot of the Power app with the Lookup function i tried but the problem is the return value is set to '12' which is the name of the column on my table (12th month). How can i have the return column change depending on the current month? 

 

LookUp(Table1,'Part Code'=Subtitle1.Text,'12')  i basically need instead of always returning value in column '12' to be able to change value based on what month it is 

powerapp.PNG
tabel.PNG
Categories:
I have the same question (0)
  • Verified answer
    wyotim Profile Picture
    2,545 on at

    Hey @PCesarRT26, I don't know of a great way to dynamically reference a column but I do have a couple suggestions for solutions to your issue.

     

    First, you could use a Switch statement along with the Month function to accomplish your goal. Here is an example:

    LookUp(
     Table1, 
     'Part Code'=Subtitle1.Text, 
     Switch(
     Month(Today()),
     1, '1',
     2, '2',
     3, '3',
     4, '4',
     5, '5',
     6, '6',
     7, '7',
     8, '8',
     9, '9',
     10, '10',
     11, '11',
     12, '12'
     )
    )

    That should work for you but I think we might be able to simplify it a bit. Galleries have a great function called ThisItem that allows an easy way to access columns of a data set by the current row the gallery is using. So instead of using a lookup, you could do the following:

    Switch(
     Month(Today()),
     1, ThisItem.'1',
     2, ThisItem.'2',
     3, ThisItem.'3',
     4, ThisItem.'4',
     5, ThisItem.'5',
     6, ThisItem.'6',
     7, ThisItem.'7',
     8, ThisItem.'8',
     9, ThisItem.'9',
     10, ThisItem.'10',
     11, ThisItem.'11',
     12, ThisItem.'12'
    )

    This simplifies the statement and lets the gallery do the work. Unless I am misunderstanding what you are doing, this would probably be the better way to go.

     

    Let me know if that solves things or if it doesn't! I'd be happy to follow up if needed!

  • PCesarRT26 Profile Picture
    on at

    This helps a lot, i am new to power apps but this makes sense as to how it works. 

    Thanks! @wyotim  

  • wyotim Profile Picture
    2,545 on at

    Well, welcome to the Power Apps family! Feel free to @ me if you have any questions or issues in the future!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard