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 / conditions and variables
Power Apps
Answered

conditions and variables

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

I have a lot of conditions in my app. I was wondering if I could use variables so I don’t get confused at the end.

Instead of doing : If ( ComboBox.Selected.Value= « Pomme » && ComboBox.Selected.Value= « Poire » ; « oui » ; « non » ) for each screen and each control.

I was wondering if I could create a variable when the user click on the button, so on the other screens, I don’t have to repeat the formula but only var1, var2, etc.

I succeed on creating a variable. It says that it’s a boolean and it’s empty.

However, I have some issues with the textbox because it should return « yes », as I selected « Pomme » and « Poire ».

Is it the best way to do so ?

Thank you

Capture d’écran (12).png
Capture d’écran (11).png
Categories:
  • Verified answer
    ANB Profile Picture
    7,252 Super User 2026 Season 1 on at

    Hi @Anonymous , If I understood your requirement then the code should be

    If(ComboBox1.Selected.Value = "Pomme" And ComboBox2.Selected.Value = "Fraise", Set(var1,true))

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    Please click Accept as solution ✅ if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs up.👍

    Thanks,
    ANB


  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you, it worked 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi. 

    I have another issue. This is the button's code : 

    If(
    ComboBox1.Selected.Value = "poire" && ComboBox2.Selected.Value = "Figue";
    Set(
    variable2;
    true
    );
    If(
    ComboBox1.Selected.Value = "pomme" && ComboBox2.Selected.Value = "fraise";
    Set(
    variable3;
    true
    )
    )
    )

    The issue is, when I select "pomme" and "fraise", it doesn't display "pomme-fraise" in the textbox. It's stuck on "poire-Figue" and I don't know why. Can you help me please ?

    Capture d’écran (14).png
  • ANB Profile Picture
    7,252 Super User 2026 Season 1 on at

    HI @Anonymous , You need to use commas not semi-colon. Please try below code:

    If(
    ComboBox1.Selected.Value = "poire" && ComboBox2.Selected.Value = "Figue",
    Set(variable2,true),
    ComboBox1.Selected.Value = "pomme" && ComboBox2.Selected.Value = "fraise",
    Set(variable3,true)
    )

      -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    Please click Accept as solution ✅ if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs up.👍

    Thanks,
    ANB


  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi, 

    I use semi colons because commas don't seem to work in France... I've always used semi colons and everything was fine. I don't think that the problem is there.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    It seems like when I reload the page, it works, whether I select "pomme" / "fraise" or "poire"/"figue". But when I select for a third time, it doesn't work. 

  • ANB Profile Picture
    7,252 Super User 2026 Season 1 on at

    Hi @Anonymous , You need to have that code on some button. Add button and then use below code:

    If(
    ComboBox1.Selected.Value = "poire" && ComboBox2.Selected.Value = "Figue",
    Set(variable2,true),
    ComboBox1.Selected.Value = "pomme" && ComboBox2.Selected.Value = "fraise",
    Set(variable3,true)
    )

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    Please click Accept as solution ✅ if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs up.👍

    Thanks,
    ANB


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 350 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 318

#3
Mohsin Ali Profile Picture

Mohsin Ali 220

Last 30 days Overall leaderboard