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 / problem with If concept
Power Apps
Unanswered

problem with If concept

(0) ShareShare
ReportReport
Posted on by 30

hi, i'm Arthur. I'm a support technician, i create an app for classing different intervention in different area and all work fine but 

i have some trouble with the if command, i don't know how to use it.
My situation.
I have a form with a drop-down. this drop-down is link to a SharePoint (multi-select column)
I want to use a if condition for update a variable.
The if condition must be something like this :
if "value" is find in "value drop down" update the variable with number 1.

i do this

 

 

If(DataCardValue8_2.Selected.Value;"07:00";Set(var7h;1));;
If(DataCardValue8_2.Selected.Value;"08:00";Set(var8h;1));;
If(DataCardValue8_2.Selected.Value;"09:00";Set(var9h;1));;
If(DataCardValue8_2.Selected.Value;"10:00";Set(var10h;1));;
If(DataCardValue8_2.Selected.Value;"11:00";Set(var11h;1));;
If(DataCardValue8_2.Selected.Value;"12:00";Set(var12h;1));;
If(DataCardValue8_2.Selected.Value;"13:00";Set(var13h;1));;
If(DataCardValue8_2.Selected.Value;"14:00";Set(var14h;1));;
If(DataCardValue8_2.Selected.Value;"15:00";Set(var15h;1));;
If(DataCardValue8_2.Selected.Value;"16:00";Set(var16h;1));;
If(DataCardValue8_2.Selected.Value;"17:00";Set(var17h;1));;
If(DataCardValue8_2.Selected.Value;"18:00";Set(var18h;1));;
If(DataCardValue8_2.Selected.Value;"19:00";Set(var19h;1));;

 

 


But in fact he don't make an if, the code update all the variable. He don't compare value i think.
Do you Have an idea ?
every help is welcome

( i need this exact information to create a bar chart)

Categories:
  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    I think you need to update the condition, so you are comparing the selected value with the time string.

    For example:

    If(DataCardValue8_2.Selected.Value = "07:00";Set(var7h;1));;
    If(DataCardValue8_2.Selected.Value = "08:00";Set(var8h;1));;
    If(DataCardValue8_2.Selected.Value = "09:00";Set(var9h;1));;
    If(DataCardValue8_2.Selected.Value = "10:00";Set(var10h;1));;
    If(DataCardValue8_2.Selected.Value = "11:00";Set(var11h;1));;
    If(DataCardValue8_2.Selected.Value = "12:00";Set(var12h;1));;
    If(DataCardValue8_2.Selected.Value = "13:00";Set(var13h;1));;
    If(DataCardValue8_2.Selected.Value = "14:00";Set(var14h;1));;
    If(DataCardValue8_2.Selected.Value = "15:00";Set(var15h;1));;
    If(DataCardValue8_2.Selected.Value = "16:00";Set(var16h;1));;
    If(DataCardValue8_2.Selected.Value = "17:00";Set(var17h;1));;
    If(DataCardValue8_2.Selected.Value = "18:00";Set(var18h;1));;
    If(DataCardValue8_2.Selected.Value = "19:00";Set(var19h;1));;

     

  • timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    Hi @arthurbeaulieu 

    For this use case, I would consider calling the Switch function like so:

    https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-if

     

    Switch(DataCardValue8_2.Selected.Value;
     "07:00";Set(var7h;1);
     "08:00";Set(var8h;1);
     "09:00";Set(var9h;1);
     "10:00";Set(var10h;1);
     etc...
    )

     

     

  • arthurbeaulieu Profile Picture
    30 on at

    thank you for the reply, as you can see the variable are empty with your method

    arthurbeaulieu_0-1639992018923.png

     

    with my first method, all variable are full of 1 

    arthurbeaulieu_1-1639992189049.png

     

  • arthurbeaulieu Profile Picture
    30 on at

    Hi ! thanks for your reply, as you can see, with your method, all my variable are empty 

    arthurbeaulieu_2-1639992466386.png

     

  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    Does DataCardValue8_2.Selected.Value return a value of "07:00", "08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00" or "19:00"? 

     

     

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard