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 / Can i use a string var...
Power Apps
Answered

Can i use a string variable value as a variable name? - URGENT!

(0) ShareShare
ReportReport
Posted on by 3,347

I would like to have a pulldown menu that will trigger a label text value.  I know how to do that part.  WHat I need to know how to do is how to use the resulting text value of that label to be used in a expression as a variable or column name.  Is this possible?  Thank you.

 

Example

 

Dropdown: ["Dogs","Cats"]

 

Label1: Dropdown.Selected.Value

 

Expression:  If(Label1.Text=3, "Good", "Bad")

 

The example may have some seemingly unreated things going on, but if I can do this, it will resolve some very complicated and repetitive if statements.  

 

Thank you.

Categories:
  • martinav Profile Picture
    3,347 on at

    I renamed this one because I'm not sure it really described what I'm trying to do.  

  • martinav Profile Picture
    3,347 on at

    Here is my actual example. 

    My pulldown drives a label value:

     

    SelectedDiscipline.Text:

     

     

    If(Dropdown1.Selected.Value="Operations Review","Oper_x0020_Appvl",
    
     If(Dropdown1.Selected.Value="Purchasing Review","Purch_x0020_Appvl",
    
     If(Dropdown1.Selected.Value="Quality Review","Quality_x0020_Appvl")))

     

     

     

    Here is the long form of my Items statement:

     

    If(Dropdown1.Selected.Value="Purchasing Review",

    If(ShowCompleted_Box_1.Value=true,

    If(Radio2_1.Selected.Value="Oldest First",SortByColumns(Filter('Engineering Change Notice', Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), SelectedDiscipline.Text,Ascending, "Engrg_x0020_Release_x0020_Date",Ascending),If(Radio2_1.Selected.Value="Part Number",SortByColumns(Filter('Engineering Change Notice', Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), "Purch_x0020_Appvl",Ascending,"Part_x0020_Number",Ascending))),

    If(Radio2_1.Selected.Value="Oldest First",SortByColumns(Filter('Engineering Change Notice', Purch_x0020_Appvl=false And Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), SelectedDiscipline.Text,Ascending, "Engrg_x0020_Release_x0020_Date",Ascending),If(Radio2_1.Selected.Value="Part Number",SortByColumns(Filter('Engineering Change Notice', Purch_x0020_Appvl=false And Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), SelectedDiscipline.Text,Ascending,"Part_x0020_Number",Ascending)))),

    If(Dropdown1.Selected.Value="Quality Review",

    If(ShowCompleted_Box_1.Value=true,

    If(Radio2_1.Selected.Value="Oldest First",SortByColumns(Filter('Engineering Change Notice', Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), SelectedDiscipline.Text,Ascending, "Engrg_x0020_Release_x0020_Date",Ascending),If(Radio2_1.Selected.Value="Part Number",SortByColumns(Filter('Engineering Change Notice', Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), SelectedDiscipline.Text,Ascending,"Part_x0020_Number",Ascending))),

    If(Radio2_1.Selected.Value="Oldest First",SortByColumns(Filter('Engineering Change Notice', Quality_x0020_Appvl=false And Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), SelectedDiscipline.Text,Ascending, "Engrg_x0020_Release_x0020_Date",Ascending),If(Radio2_1.Selected.Value="Part Number",SortByColumns(Filter('Engineering Change Notice', Quality_x0020_Appvl=false And Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), SelectedDiscipline.Text,Ascending,"Part_x0020_Number",Ascending)))),

    If(Dropdown1.Selected.Value="Operations Review",

    If(ShowCompleted_Box_1.Value=true,

    If(Radio2_1.Selected.Value="Oldest First",SortByColumns(Filter('Engineering Change Notice', Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), SelectedDiscipline.Text,Ascending, "Engrg_x0020_Release_x0020_Date",Ascending),If(Radio2_1.Selected.Value="Part Number",SortByColumns(Filter('Engineering Change Notice', Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), SelectedDiscipline.Text,Ascending,"Part_x0020_Number",Ascending))),

    If(Radio2_1.Selected.Value="Oldest First",SortByColumns(Filter('Engineering Change Notice', Oper_x0020_Appvl=false And Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), SelectedDiscipline.Text,Ascending, "Engrg_x0020_Release_x0020_Date",Ascending),If(Radio2_1.Selected.Value="Part Number",SortByColumns(Filter('Engineering Change Notice', Oper_x0020_Appvl=false And Value(ECN_x0020_Status_x0020_Powerapps0)=4 And StartsWith(Part_x0020_Number,TextInput1_1.Text)), SelectedDiscipline.Text,Ascending,"Part_x0020_Number",Ascending)))))))

    If I can use my dropdown to actually name the variable, I can cut my statement reduncancy, and shorten it (and others) by 2/3.  You can use Selected_Discipline. Text for SortByColumns sort criteria, which is great.  I need to take it another step and use the .Text for variable/column names.  The variable names in RED above are the ones I want to replace with the text in the label.

  • martinav Profile Picture
    3,347 on at

    I need to bump this one, guys.  My app is stuck at the moment.  I really want to be able to simplify my statements and not have huge if()'s going on.  Any help?

     

    Thanks

  • martinav Profile Picture
    3,347 on at

    @v-xida-msft, @CarlosFigueira, 

     

    I tagged you two because I really need someone much smarter than I to help with this one.  I'm kind of held up waiting on how to handle this.  

     

    Thank you!

  • martinav Profile Picture
    3,347 on at

    BUMP!  This is very important.  Hope to hear something asap.  Thank you!

  • martinav Profile Picture
    3,347 on at

    Bump again!!!  You dont have to take it easy on me.  If this is not possible, please say so.  I'm holding off on finishing my app on this very issue.  If its a no-go, then I have to evaluate other options.

  • Mike8 Profile Picture
    1,330 on at

    Hello martinav,

    As far as I know you can't  use a string variable value as a variable name.
    Also you can't use the resulting text value of that label to be used in a expression as a variable or column name.

  • martinav Profile Picture
    3,347 on at

    I was afraid of that.  I usually get many more replies much quicker with other posts.  I was figuring this was a no-go.  Looks like I have to do some very long if statements with lots of complex and repetitive statements to get this done.

  • Verified answer
    Mike8 Profile Picture
    1,330 on at

    Yes.. 😞
    You can also use the Switch() function. It isn't what you were looking for but it may save you a few lines of code.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard