Nested IF Expressions within Flow

%3CLINGO-SUB%20id%3D%22lingo-sub-1036496%22%20slang%3D%22en-US%22%3ENested%20IF%20Expressions%20within%20Flow%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1036496%22%20slang%3D%22en-US%22%3E%3CP%3EHi.%26nbsp%3B%20I%20am%20trying%20to%20use%20nested%20IF%20expressions%20to%20populate%20a%20Word%20template%20with%20Flow.%26nbsp%3B%20Although%20the%20expression%20is%20accepted%20and%20the%20flow%20reports%20that%20it%20has%20run%20successfully%2C%20the%20template%20is%20not%20populated%20correctly.%26nbsp%3B%20An%20example%20is%20below%20(sorry%20it's%20huge...)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSTRONG%3E%3CEM%3E%3CSPAN%3Eif(equals(body(%3C%2FSPAN%3E%3CSPAN%3E'Get_response_details'%3C%2FSPAN%3E%3CSPAN%3E)%3F%5B%3C%2FSPAN%3E%3CSPAN%3E'rb74aa75486494313bcbbd14debd63c5d'%3C%2FSPAN%3E%3CSPAN%3E%5D%2C%3C%2FSPAN%3E%3CSPAN%3E'No'%3C%2FSPAN%3E%3CSPAN%3E)%2C%3C%2FSPAN%3E%3CSPAN%3E'All%20staff%20have%20completed%20the%20mandatory%20eLearning%20modules%20within%20the%20last%20year%20for%20the%20destination%20in%20which%20they%20are%20based.%20'%3C%2FSPAN%3E%3CSPAN%3E%2Cif(equals(body(%3C%2FSPAN%3E%3CSPAN%3E'Get_response_details'%3C%2FSPAN%3E%3CSPAN%3E)%3F%5B%3C%2FSPAN%3E%3CSPAN%3E'r510000c87b1a4870aabd7d54cde00088'%3C%2FSPAN%3E%3CSPAN%3E%5D%2C%3C%2FSPAN%3E%3CSPAN%3E'No'%3C%2FSPAN%3E%3CSPAN%3E)%2C%3C%2FSPAN%3E%3CSPAN%3E'Have%20risk%20assessments%20been%20completed%20for%20any%20colleague%20who%20is%20pregnant%2C%20is%20a%20disabled%20person%2C%20is%20a%20wheelchair%20user%2C%20has%20learning%20difficulties%2C%20has%20cerebral%20palsy%2C%20has%20a%20mental%20health%20condition%2C%20is%20a%20person%20with%20a%20hearing%20impairment%2C%20is%20a%20person%20with%20a%20visual%20impairment%2C%20is%20a%20person%20with%20epilepsy%2C%20diabetes%2C%20who%20has%20depression%2C%20has%20restricted%20growth%20or%20short%20stature%20or%20who%20suffers%20from%20seizures%3F%26nbsp%3B%20These%20should%20be%20filed%20in%20the%20Risk%20Assessment%20Register%20(RAR)%20and%20retained%20for%203%20years.%20'%3C%2FSPAN%3E%3CSPAN%3E%2Cif(equals(body(%3C%2FSPAN%3E%3CSPAN%3E'Get_response_details'%3C%2FSPAN%3E%3CSPAN%3E)%3F%5B%3C%2FSPAN%3E%3CSPAN%3E'r8875e99cb17a403c850d849c67d61ee9'%3C%2FSPAN%3E%3CSPAN%3E%5D%2C%3C%2FSPAN%3E%3CSPAN%3E'No'%3C%2FSPAN%3E%3CSPAN%3E)%2C%3C%2FSPAN%3E%3CSPAN%3E'All%20risk%20assessments%20are%20kept%20in%20the%20Risk%20Assessment%20Register%20and%20reviewed%20annually.%26nbsp%3B%20Each%20risk%20assessment%20should%20be%20kept%20for%20as%20long%20as%20it%20is%20applicable%20and%20for%20at%20least%203%20years%20following%20its%20last%20application.%20'%3C%2FSPAN%3E%3CSPAN%3E%2Cif(equals(body(%3C%2FSPAN%3E%3CSPAN%3E'Get_response_details'%3C%2FSPAN%3E%3CSPAN%3E)%3F%5B%3C%2FSPAN%3E%3CSPAN%3E'r11b068e6afe54166a9437cca4fe2f146'%3C%2FSPAN%3E%3CSPAN%3E%5D%2C%3C%2FSPAN%3E%3CSPAN%3E'No'%3C%2FSPAN%3E%3CSPAN%3E)%2C%3C%2FSPAN%3E%3CSPAN%3E'Risk%20assessments%20have%20been%20completed%20for%20airport%20duties%20and%20filed%20in%20the%20RAR.%20'%3C%2FSPAN%3E%3CSPAN%3E%2Cif(equals(body(%3C%2FSPAN%3E%3CSPAN%3E'Get_response_details'%3C%2FSPAN%3E%3CSPAN%3E)%3F%5B%3C%2FSPAN%3E%3CSPAN%3E're445b39a97c54983aa421bb7ebe2adfe'%3C%2FSPAN%3E%3CSPAN%3E%5D%2C%3C%2FSPAN%3E%3CSPAN%3E'No'%3C%2FSPAN%3E%3CSPAN%3E)%2C%3C%2FSPAN%3E%3CSPAN%3E'Display%20Screen%20Equipment%20(DSE)%20risk%20assessments%20have%20been%20completed%20for%20each%20office%20based%20member%20of%20staff.%26nbsp%3B%20These%20are%20filed%20in%20the%20RAR.%20'%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E'No%20Serious%20Concerns%20Raised.%20'%3C%2FSPAN%3E%3CSPAN%3E)))))%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20all%20the%20responses%20are%20No%20when%20completing%20the%20Form%2C%20it%20will%20only%20populate%20the%20template%20with%20the%20first%20statement%20(%22%3CSPAN%3EAll%20staff%20have%20completed%20the%20mandatory%20eLearning%20modules%20within%20the%20last%20year%20for%20the%20destination%20in%20which%20they%20are%20based.%3CFONT%20color%3D%22%23b01600%22%3E%22)%3C%2FFONT%3E%3C%2FSPAN%3E%2C%20ignoring%20the%20remaining%20%22nested%22%20conditions.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20anyone%20assist%2C%20please%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMany%20thanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1036496%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Flow%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1037568%22%20slang%3D%22en-US%22%3ERe%3A%20Nested%20IF%20Expressions%20within%20Flow%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1037568%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F115165%22%20target%3D%22_blank%22%3E%40Matt%20Bryant%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20you%20are%20well.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20having%20a%20squiz%20at%20your%20expression%20and%20the%20logic%20doesn't%20quite%20make%20sense%20to%20me%20(there%20may%20be%20things%20in%20your%20flow%20that%20you%20haven't%20shown%20or%20described%20here%20so%20I%20will%20make%20some%20assumptions).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20the%20%3CSTRONG%3Efirst%20answer%3C%2FSTRONG%3E%26nbsp%3Bto%20the%20question%20is%20%3CSTRONG%3ENo%3C%2FSTRONG%3E%20then%20it%20will%20print%20%3CEM%3E%22%3C%2FEM%3E%3CSPAN%3E%3CEM%3EAll%20staff%20have%20completed%20the%20mandatory%20eLearning%20modules%20within%20the%20last%20year%20for%20the%20destination%20in%20which%20they%20are%20based%22%26nbsp%3B%3C%2FEM%3Eand%20stop%20there%20and%20ignore%20the%20other%20conditions.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThe%20first%20part%20of%20the%20expression%20is%20only%20checking%20one%20question%2C%20so%20how%20will%20know%20that%20all%20four%20questions%20are%20answered%20to%20meet%20this%20condition%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThe%20same%20applies%20if%20you%20make%20it%20to%20%3CSTRONG%3Equestion%20two%3C%2FSTRONG%3E%20and%20the%20answer%20is%20%3CSTRONG%3ENo%3C%2FSTRONG%3E%26nbsp%3Band%20so%20forth.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EAre%20you%20looking%20to%20to%20check%20against%20all%20questions%20and%20execute%20the%20IF%20statements%20to%20vet%20each%20answer%2C%20or%20do%20you%20want%20to%20stop%20when%20a%20condition%20is%20met%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EIf%20you%20could%20please%20outline%20your%20logic%2C%20it%20would%20help%20figure%20out%20what's%20happening.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ECheers%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EDamien%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1037576%22%20slang%3D%22en-US%22%3ERe%3A%20Nested%20IF%20Expressions%20within%20Flow%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1037576%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20again%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F115165%22%20target%3D%22_blank%22%3E%40Matt%20Bryant%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20an%20additional%20post%20to%20my%20earlier%20response%20and%20on%20an%20assumption%2C%20have%20you%20tried%20using%20Condition%20to%20break%20down%20your%20requirements%20in%20a%20user%20friendly%20way%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20needed%20to%20vet%20the%20combos%20(e.g.%20all%20No%2C%203%20No%20and%201%20Yes%2C%202%20No%20and%202%20Yes%2C%20etc)%20then%20using%20nested%20conditions%20gives%20you%20a%20GUI%20to%20set%20your%20conditions%20by%20and%20to%20then%20execute%20that%20particular%20result%20you%20are%20seeking.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F159295i4026CAB3F26E4B41%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22capture20191128175704670.png%22%20title%3D%22capture20191128175704670.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%20in%20some%20way%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3CP%3EDamien%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1037703%22%20slang%3D%22en-US%22%3ERe%3A%20Nested%20IF%20Expressions%20within%20Flow%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1037703%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F89704%22%20target%3D%22_blank%22%3E%40Damien%20Rosario%3C%2FA%3E%26nbsp%3B%20-%20thanks%20for%20getting%20back%20so%20quickly.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20a%20bit%20of%20background%2C%20I%20am%20creating%20a%20compliance%20self-assessment%20for%20our%20various%20offices%20to%20complete.%26nbsp%3B%20The%20final%20page%20of%20the%20document%20that%20is%20produced%20lists%20any%20high-priority%20concerns%20from%20each%20section%20of%20the%20assessment.%26nbsp%3B%20Where%20none%20of%20these%20concerns%20are%20identified%2C%20I%20would%20like%20to%20say%20%22No%20concerns%20identified%22%20or%20similar%2C%20rather%20than%20just%20leaving%20the%20section%20blank.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20formula%20I%20have%20written%20is%20based%20on%20Excel%2C%20but%20it%20is%20clearly%20not%20quite%20right%20for%20Flow!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMatt.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1039056%22%20slang%3D%22en-US%22%3ERe%3A%20Nested%20IF%20Expressions%20within%20Flow%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1039056%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F115165%22%20target%3D%22_blank%22%3E%40Matt%20Bryant%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBlah%20so%20my%20entire%20post%20failed%20to%20upload%20so%20I'm%20doing%20this%20again.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20still%20not%20quite%20clear%20on%20your%20set%20up%2C%20are%20you%20using%20a%20single%20field%20in%20your%20doc%20to%20display%20the%20result%20from%20your%20IF%20statement%2C%20or%20are%20you%20looking%20to%20have%20each%20questions%20result%20in%20the%20doc%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%20in%20case%20you%20want%20further%20options%20and%20other%20opinions%2C%20you%20can%20try%20the%20experts%20at%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fpowerusers.microsoft.com%2Ft5%2FPowerApps-Community%2Fct-p%2FPowerApps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fpowerusers.microsoft.com%2Ft5%2FPowerApps-Community%2Fct-p%2FPowerApps1%3C%2FA%3E.%20These%20guys%20are%20insanely%20amazing.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20happy%20to%20help%20explore%20what%20to%20do%20but%20I%20will%20need%20more%20info%20as%20it's%20tough%20to%20diagnose%20something%20without%20knowing%20what%20outputs%20you%20want%20in%20the%20last%20page%20of%20the%20doc.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBest%20wishes%20for%20the%20weekend%20ahead%3C%2FP%3E%3CP%3EDamien%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi.  I am trying to use nested IF expressions to populate a Word template with Flow.  Although the expression is accepted and the flow reports that it has run successfully, the template is not populated correctly.  An example is below (sorry it's huge...):

 

if(equals(body('Get_response_details')?['rb74aa75486494313bcbbd14debd63c5d'],'No'),'All staff have completed the mandatory eLearning modules within the last year for the destination in which they are based. ',if(equals(body('Get_response_details')?['r510000c87b1a4870aabd7d54cde00088'],'No'),'Have risk assessments been completed for any colleague who is pregnant, is a disabled person, is a wheelchair user, has learning difficulties, has cerebral palsy, has a mental health condition, is a person with a hearing impairment, is a person with a visual impairment, is a person with epilepsy, diabetes, who has depression, has restricted growth or short stature or who suffers from seizures?  These should be filed in the Risk Assessment Register (RAR) and retained for 3 years. ',if(equals(body('Get_response_details')?['r8875e99cb17a403c850d849c67d61ee9'],'No'),'All risk assessments are kept in the Risk Assessment Register and reviewed annually.  Each risk assessment should be kept for as long as it is applicable and for at least 3 years following its last application. ',if(equals(body('Get_response_details')?['r11b068e6afe54166a9437cca4fe2f146'],'No'),'Risk assessments have been completed for airport duties and filed in the RAR. ',if(equals(body('Get_response_details')?['re445b39a97c54983aa421bb7ebe2adfe'],'No'),'Display Screen Equipment (DSE) risk assessments have been completed for each office based member of staff.  These are filed in the RAR. ','No Serious Concerns Raised. ')))))

 

If all the responses are No when completing the Form, it will only populate the template with the first statement ("All staff have completed the mandatory eLearning modules within the last year for the destination in which they are based."), ignoring the remaining "nested" conditions.

 

Can anyone assist, please?

 

Many thanks.

4 Replies
Highlighted

Hi @Matt Bryant 

 

Hope you are well.

 

I'm having a squiz at your expression and the logic doesn't quite make sense to me (there may be things in your flow that you haven't shown or described here so I will make some assumptions).

 

If the first answer to the question is No then it will print "All staff have completed the mandatory eLearning modules within the last year for the destination in which they are based" and stop there and ignore the other conditions. 

 

The first part of the expression is only checking one question, so how will know that all four questions are answered to meet this condition?

 

The same applies if you make it to question two and the answer is No and so forth.

 

Are you looking to to check against all questions and execute the IF statements to vet each answer, or do you want to stop when a condition is met?

 

If you could please outline your logic, it would help figure out what's happening.

 

Cheers

Damien

Highlighted

Hi again @Matt Bryant 

 

As an additional post to my earlier response and on an assumption, have you tried using Condition to break down your requirements in a user friendly way? 

 

If you needed to vet the combos (e.g. all No, 3 No and 1 Yes, 2 No and 2 Yes, etc) then using nested conditions gives you a GUI to set your conditions by and to then execute that particular result you are seeking.

 

capture20191128175704670.png

 

Hope that helps in some way?

 

Cheers

Damien

Highlighted

Hi @Damien Rosario  - thanks for getting back so quickly.

 

For a bit of background, I am creating a compliance self-assessment for our various offices to complete.  The final page of the document that is produced lists any high-priority concerns from each section of the assessment.  Where none of these concerns are identified, I would like to say "No concerns identified" or similar, rather than just leaving the section blank.

 

The formula I have written is based on Excel, but it is clearly not quite right for Flow!

 

Matt.

Highlighted

Hi @Matt Bryant

 

Blah so my entire post failed to upload so I'm doing this again.

 

I'm still not quite clear on your set up, are you using a single field in your doc to display the result from your IF statement, or are you looking to have each questions result in the doc?

 

Also in case you want further options and other opinions, you can try the experts at https://powerusers.microsoft.com/t5/PowerApps-Community/ct-p/PowerApps1. These guys are insanely amazing.

 

I'm happy to help explore what to do but I will need more info as it's tough to diagnose something without knowing what outputs you want in the last page of the doc.

 

Best wishes for the weekend ahead

Damien