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 Apps
Answered

If Function

(0) ShareShare
ReportReport
Posted on by 23

Hello everyone,

    i am a bit of a newbie in power apps. I'm trying to add 2 or more istructions in the IF true branch but if I use the ; it goes on the false branch. 

Basically my question is: I have this code:

 

 

 

 

 

Set(
 showPopup;
 false
);;
If(
 (Toggle1.Value = false && Toggle2.Value = false && Toggle3.Value = false && Toggle4.Value = false);
 Collect(
 tblInserimento;
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica.Text;
 N_SERIE: txtSerie.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer.Text;
 PESO_ton: txtPeso.Text;
 CODICE_UTI: txtUti.Text;
 NOTE: txtNote.Text
 }
 )
);;
If(
 (Toggle1.Value = true && Toggle2.Value = false && Toggle3.Value = false && Toggle4.Value = false);
 If(
 (txtUti.Text <> txtUti_1.Text);
 Collect(
 tblInserimento;
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica.Text;
 N_SERIE: txtSerie.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer.Text;
 PESO_ton: txtPeso.Text;
 CODICE_UTI: txtUti.Text;
 NOTE: txtNote.Text
 };
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica_1.Text;
 N_SERIE: txtSerie_1.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer_1.Text;
 PESO_ton: txtPeso_1.Text;
 CODICE_UTI: txtUti_1.Text;
 NOTE: txtNote_1.Text
 }
 );
 UpdateContext({showPopup: true})
 )
);;
If(
 (Toggle1.Value = true && Toggle2.Value = true && Toggle3.Value = false && Toggle4.Value = false);
 If(
 (txtUti.Text <> txtUti_1.Text && txtUti.Text <> txtUti_2.Text && txtUti_1.Text <> txtUti_2.Text);
 Collect(
 tblInserimento;
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica.Text;
 N_SERIE: txtSerie.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer.Text;
 PESO_ton: txtPeso.Text;
 CODICE_UTI: txtUti.Text;
 NOTE: txtNote.Text
 };
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica_1.Text;
 N_SERIE: txtSerie_1.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer_1.Text;
 PESO_ton: txtPeso_1.Text;
 CODICE_UTI: txtUti_1.Text;
 NOTE: txtNote_1.Text
 };
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica_2.Text;
 N_SERIE: txtSerie_2.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer_2.Text;
 PESO_ton: txtPeso_2.Text;
 CODICE_UTI: txtUti_2.Text;
 NOTE: txtNote_2.Text
 }
 );
 UpdateContext({showPopup: true})
 )
);;
If(
 (Toggle1.Value = true && Toggle2.Value = true && Toggle3.Value = true && Toggle4.Value = false);
 If(
 (txtUti.Text <> txtUti_1.Text && txtUti.Text <> txtUti_2.Text && txtUti.Text <> txtUti_3.Text && txtUti_1.Text <> txtUti_2.Text && txtUti_1.Text <> txtUti_3.Text && txtUti_2.Text <> txtUti_3.Text);
 Collect(
 tblInserimento;
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica.Text;
 N_SERIE: txtSerie.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer.Text;
 PESO_ton: txtPeso.Text;
 CODICE_UTI: txtUti.Text;
 NOTE: txtNote.Text
 };
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica_1.Text;
 N_SERIE: txtSerie_1.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer_1.Text;
 PESO_ton: txtPeso_1.Text;
 CODICE_UTI: txtUti_1.Text;
 NOTE: txtNote_1.Text
 };
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica_2.Text;
 N_SERIE: txtSerie_2.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer_2.Text;
 PESO_ton: txtPeso_2.Text;
 CODICE_UTI: txtUti_2.Text;
 NOTE: txtNote_2.Text
 };
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica_3.Text;
 N_SERIE: txtSerie_3.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer_3.Text;
 PESO_ton: txtPeso_3.Text;
 CODICE_UTI: txtUti_3.Text;
 NOTE: txtNote_3.Text
 }
 );
 UpdateContext({showPopup: true})
 )
);;
If(
 (Toggle1.Value = true && Toggle2.Value = true && Toggle3.Value = true && Toggle4.Value = true);
 If(
 (txtUti.Text <> txtUti_1.Text && txtUti.Text <> txtUti_2.Text && txtUti.Text <> txtUti_3.Text && txtUti.Text <> txtUti_4.Text && txtUti_1.Text <> txtUti_2.Text && txtUti_1.Text <> txtUti_3.Text && txtUti_1.Text <> txtUti_4.Text && txtUti_2.Text <> txtUti_3.Text && txtUti_2.Text <> txtUti_4.Text && txtUti_3.Text <> txtUti_4.Text);
 Collect(
 tblInserimento;
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica.Text;
 N_SERIE: txtSerie.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer.Text;
 PESO_ton: txtPeso.Text;
 CODICE_UTI: txtUti.Text;
 NOTE: txtNote.Text
 };
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica_1.Text;
 N_SERIE: txtSerie_1.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer_1.Text;
 PESO_ton: txtPeso_1.Text;
 CODICE_UTI: txtUti_1.Text;
 NOTE: txtNote_1.Text
 };
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica_2.Text;
 N_SERIE: txtSerie_2.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer_2.Text;
 PESO_ton: txtPeso_2.Text;
 CODICE_UTI: txtUti_2.Text;
 NOTE: txtNote_2.Text
 };
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica_3.Text;
 N_SERIE: txtSerie_3.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer_3.Text;
 PESO_ton: txtPeso_3.Text;
 CODICE_UTI: txtUti_3.Text;
 NOTE: txtNote_3.Text
 };
 {
 DATA_TRENO: dataTreno.SelectedDate;
 N_NOTIFICA: txtNotifica_4.Text;
 N_SERIE: txtSerie_4.Text;
 RELAZIONE: dropRelazione.Selected.Value;
 N_TRENO: txtTreno.Text;
 ORIGINE: dropOrigine.Selected.Value;
 CER: txtCer_4.Text;
 PESO_ton: txtPeso_4.Text;
 CODICE_UTI: txtUti_4.Text;
 NOTE: txtNote_4.Text
 }
 );
 UpdateContext({showPopup: true})
 )
);;
If(
 showPopup = false;
 Navigate(Stato)
)

 

i want the last IF (If(showPopup = false; Navigate(Stato));;) to be executed if the Collect in any IF is executed.

 

Can somebody help me?

 

ps I use power apps from the browser

 

Categories:
  • SebS Profile Picture
    4,874 Super User 2026 Season 2 on at

    @benini_simone 

     

    I do not have a way to check if this will work:

     

    I added clear collect to make sure Your collection always start from scratch

     

    ClearCollect(
     tblInserimento,
     If(
     (Toggle1.Value = false && Toggle2.Value = false && Toggle3.Value = false && Toggle4.Value = false),
     {
     DATA_TRENO: dataTreno.SelectedDate;
     N_NOTIFICA: txtNotifica.Text;
     N_SERIE: txtSerie.Text;
     RELAZIONE: dropRelazione.Selected.Value;
     N_TRENO: txtTreno.Text;
     ORIGINE: dropOrigine.Selected.Value;
     CER: txtCer.Text;
     PESO_ton: txtPeso.Text;
     CODICE_UTI: txtUti.Text;
     NOTE: txtNote.Text
     },
     {}
     )
    );
    
    If (
     (Toggle1.Value = true && Toggle2.Value = false && Toggle3.Value = false && Toggle4.Value = false),
     If (
     txtUti.Text <> txtUti_1.Text,
     ClearCollect(
     tblInserimento,
     {
     DATA_TRENO: dataTreno.SelectedDate;
     N_NOTIFICA: txtNotifica.Text;
     N_SERIE: txtSerie.Text;
     RELAZIONE: dropRelazione.Selected.Value;
     N_TRENO: txtTreno.Text;
     ORIGINE: dropOrigine.Selected.Value;
     CER: txtCer.Text;
     PESO_ton: txtPeso.Text;
     CODICE_UTI: txtUti.Text;
     NOTE: txtNote.Text
     },
     {
     DATA_TRENO: dataTreno.SelectedDate;
     N_NOTIFICA: txtNotifica_1.Text;
     N_SERIE: txtSerie_1.Text;
     RELAZIONE: dropRelazione.Selected.Value;
     N_TRENO: txtTreno.Text;
     ORIGINE: dropOrigine.Selected.Value;
     CER: txtCer_1.Text;
     PESO_ton: txtPeso_1.Text;
     CODICE_UTI: txtUti_1.Text;
     NOTE: txtNote_1.Text
     }
     );
     UpdateContext({ showPopup: true })
     )
    );
    
    If (showPopup = false, Navigate(Stato));
  • benini_simone Profile Picture
    23 on at

    I can't add ClearCollect to the code because the app add records to a file excel and previous records needs to stay in the file. 

    My main issue is being able to have more than one instruction in the true branch of the IF function. 

    Is that possibile?

  • SebS Profile Picture
    4,874 Super User 2026 Season 2 on at

    @benini_simone 

     

    In this case, you could try this :

     

     

     

    If(
     (Toggle1.Value = false && Toggle2.Value = false && Toggle3.Value = false && Toggle4.Value = false),
     /* True branch for the first condition */
     Collect(
     tblInserimento,
     {
     DATA_TRENO: dataTreno.SelectedDate,
     N_NOTIFICA: txtNotifica.Text,
     N_SERIE: txtSerie.Text,
     RELAZIONE: dropRelazione.Selected.Value,
     N_TRENO: txtTreno.Text,
     ORIGINE: dropOrigine.Selected.Value,
     CER: txtCer.Text,
     PESO_ton: txtPeso.Text,
     CODICE_UTI: txtUti.Text,
     NOTE: txtNote.Text
     }
     ),
     /* True branch for the second condition */
     If (
     Toggle1.Value = true && Toggle2.Value = false && Toggle3.Value = false && Toggle4.Value = false,
     If (
     txtUti.Text <> txtUti_1.Text,
     Collect(
     tblInserimento,
     {
     DATA_TRENO: dataTreno.SelectedDate,
     N_NOTIFICA: txtNotifica.Text,
     N_SERIE: txtSerie.Text,
     RELAZIONE: dropRelazione.Selected.Value,
     N_TRENO: txtTreno.Text,
     ORIGINE: dropOrigine.Selected.Value,
     CER: txtCer.Text,
     PESO_ton: txtPeso.Text,
     CODICE_UTI: txtUti.Text,
     NOTE: txtNote.Text
     },
     {
     DATA_TRENO: dataTreno.SelectedDate,
     N_NOTIFICA: txtNotifica_1.Text,
     N_SERIE: txtSerie_1.Text,
     RELAZIONE: dropRelazione.Selected.Value,
     N_TRENO: txtTreno.Text,
     ORIGINE: dropOrigine.Selected.Value,
     CER: txtCer_1.Text,
     PESO_ton: txtPeso_1.Text,
     CODICE_UTI: txtUti_1.Text,
     NOTE: txtNote_1.Text
     }
     );
     UpdateContext({ showPopup: true })
     )
     )
    );
    
    If (showPopup = false, Navigate(Stato));

     

     

  • benini_simone Profile Picture
    23 on at

    It won't accept the code, i cannot use the comma. I don't have (or better cannot find it anywhere) the power app studio.

  • SebS Profile Picture
    4,874 Super User 2026 Season 2 on at

    @benini_simone 

     

    I correct it have a look now

  • benini_simone Profile Picture
    23 on at

    Not correct, there are still commas in the collect and in the If conditions...

  • SebS Profile Picture
    4,874 Super User 2026 Season 2 on at

    @benini_simone 

     

    My Power FX using "," as separator just replace them with whatever is expected

     

     

     

  • benini_simone Profile Picture
    23 on at

    I tried. It doesn't work anyway. 

  • SebS Profile Picture
    4,874 Super User 2026 Season 2 on at

    @benini_simone 

     

    I tried, but I don't have a way now to check the code, or I will need to recreate all tables. Maybe after work, I will have more time and see if I can verify it and check it for You.

     

     

  • benini_simone Profile Picture
    23 on at

    Thanks, if it helps the issue is just that doesn't navigate to the screen Stato. All the rest works perfectly and add the record to the file excel correctly. 

     

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 283

#3
Mohsin Ali Profile Picture

Mohsin Ali 221

Last 30 days Overall leaderboard