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 / multiple if structure
Power Apps
Unanswered

multiple if structure

(0) ShareShare
ReportReport
Posted on by 9

Im new at power apps, and i dont understand why i cant put multiple if in a single button

I'm trying to make a button with restrictions. I have two other text fields, and I want to put several restrictions, but show them all. If the fields are not filled in, show them first. Then if the fields are filled out in bad format, let them tell you. But I also want that if one is not filled out, and another is in bad format, that I inform you of both errors. Here is my code, could someone help me? Thanks
HERE THE CODE

If(
    IsBlank(TextoNIF.Text);
    Notify("Error: Debes rellenar el campo NIF."; NotificationType.Error);
    If(
        Len(TextoNIF.Text) <> 10 || !IsNumeric(Mid(TextoNIF.Text; 1; 9)) || !(IsNumeric(Mid(TextoNIF.Text; 10; 1)) && Lower(Mid(TextoNIF.Text; 10; 1)) <> Mid(TextoNIF.Text; 10; 1));
        Notify("Error: El formato del campo NIF no es correcto. Debe tener 9 números seguidos de una letra."; NotificationType.Error)
    )
)

// Validación del campo justificante
If( //here power apps tells me there is a problem with syntaxis, but i dont know why
    IsBlank(TextoJustificante.Text);
    Notify("Error: Debes rellenar el campo Nº justificante."; NotificationType.Error);
    If(
        Len(TextoJustificante.Text) <> 13 || !IsNumeric(TextoJustificante.Text) || Len(TextoJustificante.Text) = 0;
        Notify("Error: El campo Nº justificante debe tener exactamente 13 dígitos numéricos."; NotificationType.Error)
    )
)

// Resto del código si las validaciones son exitosas
If(
    !IsBlank(TextoNIF.Text) && (Len(TextoNIF.Text) = 10 && IsNumeric(Mid(TextoNIF.Text; 1; 9)) && (IsNumeric(Mid(TextoNIF.Text; 10; 1)) && Lower(Mid(TextoNIF.Text; 10; 1)) <> Mid(TextoNIF.Text; 10; 1))) &&
    !IsBlank(TextoJustificante.Text) && (Len(TextoJustificante.Text) = 13 && IsNumeric(TextoJustificante.Text));
    Navigate(PantallaResultados; ScreenTransition.Cover)
)
Categories:
I have the same question (0)
  • SpongYe Profile Picture
    5,909 Super User 2026 Season 1 on at

    Hi @Pdeazcarate 

     

    You could also use the If statement as follows:

    If(Condition1, ThenResult1 [, Condition2, ThenResult2, ... [ , DefaultResult ] ] )

    https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-if#syntax

    In your case:

    // Validación del campo NIF
    If(
     IsBlank(TextoNIF.Text),
     Notify("Error: Debes rellenar el campo NIF.", NotificationType.Error),
     Len(TextoNIF.Text) <> 10 || !IsNumeric(Mid(TextoNIF.Text, 1, 9)) || !(IsNumeric(Mid(TextoNIF.Text, 10, 1)) && Lower(Mid(TextoNIF.Text, 10, 1)) <> Mid(TextoNIF.Text, 10, 1)),
     Notify("Error: El formato del campo NIF no es correcto. Debe tener 9 números seguidos de una letra.", NotificationType.Error)
    )
    
    // Validación del campo justificante
    If(
     IsBlank(TextoJustificante.Text),
     Notify("Error: Debes rellenar el campo Nº justificante.", NotificationType.Error),
     Len(TextoJustificante.Text) <> 13 || !IsNumeric(TextoJustificante.Text) || Len(TextoJustificante.Text) = 0,
     Notify("Error: El campo Nº justificante debe tener exactamente 13 dígitos numéricos.", NotificationType.Error)
    )
    
    // Resto del código si las validaciones son exitosas
    If(
     !IsBlank(TextoNIF.Text) && (Len(TextoNIF.Text) = 10 && IsNumeric(Mid(TextoNIF.Text, 1, 9)) && (IsNumeric(Mid(TextoNIF.Text, 10, 1)) && Lower(Mid(TextoNIF.Text, 10, 1)) <> Mid(TextoNIF.Text, 10, 1))) &&
     !IsBlank(TextoJustificante.Text) && (Len(TextoJustificante.Text) = 13 && IsNumeric(TextoJustificante.Text)),
     Navigate(PantallaResultados, ScreenTransition.Cover)
    )

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

  • Pdeazcarate Profile Picture
    9 on at

    Hello, i still have the same error. My format is european so i use ; instead of comas. In the first if at the end where I close the parenthesis it tells me the following error: unexpected characters. I tried using comas but its worse. Do you know why could it be? Thanks

  • SpongYe Profile Picture
    5,909 Super User 2026 Season 1 on at

    Hi @Pdeazcarate 

     

    Sorry for the confusion I had to edit for my testing purpose. I adjusted the code a little more because each condition in an If function needs to be paired with a result. The issue I think is likely due to the structure of your If statements:

     

    // Validación del campo NIF
    If(
     IsBlank(TextoNIF.Text);
     Notify("Error: Debes rellenar el campo NIF."; NotificationType.Error);
     Len(TextoNIF.Text) <> 10 || !IsNumeric(Mid(TextoNIF.Text; 1; 9)) || !(IsNumeric(Mid(TextoNIF.Text; 10; 1)) && Lower(Mid(TextoNIF.Text; 10; 1)) <> Mid(TextoNIF.Text; 10; 1));
     Notify("Error: El formato del campo NIF no es correcto. Debe tener 9 números seguidos de una letra."; NotificationType.Error);
     true
    )
    
    // Validación del campo justificante
    If(
     IsBlank(TextoJustificante.Text);
     Notify("Error: Debes rellenar el campo Nº justificante."; NotificationType.Error);
     Len(TextoJustificante.Text) <> 13 || !IsNumeric(TextoJustificante.Text);
     Notify("Error: El campo Nº justificante debe tener exactamente 13 dígitos numéricos."; NotificationType.Error);
     true
    )
    
    // Resto del código si las validaciones son exitosas
    If(
     !IsBlank(TextoNIF.Text) && Len(TextoNIF.Text) = 10 && IsNumeric(Mid(TextoNIF.Text; 1; 9)) && (IsNumeric(Mid(TextoNIF.Text; 10; 1)) && Lower(Mid(TextoNIF.Text; 10; 1)) <> Mid(TextoNIF.Text; 10; 1)) &&
     !IsBlank(TextoJustificante.Text) && Len(TextoJustificante.Text) = 13 && IsNumeric(TextoJustificante.Text);
     Navigate(PantallaResultados; ScreenTransition.Cover)
    )

     If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

  • Pdeazcarate Profile Picture
    9 on at

    Hello, i just have seen the solutio, sorry for not replying. I just proved it but it still doesnt work. Dont worry ill try for myself just for not annoying you with that. Thanks anyways!

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 326 Most Valuable Professional

#2
11manish Profile Picture

11manish 168

#3
sannavajjala87 Profile Picture

sannavajjala87 75 Super User 2026 Season 1

Last 30 days Overall leaderboard