cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Caitlin_Knox1
Level: Powered On

Advanced edit condition

I am REALLY hoping someone can help me out.

What started this journey to advanced conditions is that I was running into a problem where Flow was telling me that it was unable to process template language expressions (https://powerusers.microsoft.com/t5/I-Found-A-Bug/Unable-to-process-template-language-expressions-in... )

All I'm really trying to do is use the value of a cell (Excel table) in my condition logic. It worked once when I wrapped my value in ' ' but for some reason didn't work for the other threshold I added in the no branch. Thus, I pivoted to Advanced edit. 

This is what I have so far, but the error message I get back here is a generic 'Invalid Response'

 

The syntax I'm (trying) to use are the following

less(float( body('Get_a_Row')?['output'] ),3)

less(float( body('Get_a_Row')?['output'] ),6)

greater(float( body('Get_a_Row')?['output'] ),6)

 

I linked the aforementioned screenshots of the error message & then the structure of my flow. Trying to use the output of 'Get Rows' for the condition

screenshots 

1 ACCEPTED SOLUTION

Accepted Solutions
Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

I know you are all DYING to know the outcome lol. I am happy to report that I got this working. I put the logic in the Excel sheet that I was trying to use in Flow. The output of that was the text "Less3" "Less6" "Greater6" as suggested. I added this row to the Table, with its own special Power Apps ID to be used as dynamic content in my Flow. I like the Switch model the best, so that's what my production Flow uses.

Thanks again for all the help, this was a tricky one!

View solution in original post

19 REPLIES 19
Super User
Super User

Re: Advanced edit condition

@Caitlin_Knox1 

Hi there!  Wow, so much to unpack here.  Great job documenting everything, btw.

Ok, so I want to step through the simple stuff first.  Can you please post the json output of the Get Row step?  I'm guessing there's a column called 'Output', right?  So, specifically that field.  Once I have that, I can start mocking up some things.

 

Thanks!

-Ed-

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

Thank you for replying! I've been battling this all week and would love to get it wrapped up. I so appreciate you.

 

Just some context on the logic. There are 3 different conditional branches. one for under 3, one for under 6 (greater than 3, less than 6) and then greater than 6. This specific value 46.9 i would expect to generate the 3rd templated email for greater than 6

 

JSON output from ‘Get Row’ action

{

  "@odata.context": "https://excelonline-eus2.azconn-eus2.p.azurewebsites.net/$metadata#drives('b%21dcKhzg3g-0yr_gL8uGcIi...",

  "@odata.etag": "",

  "ItemInternalId": "8IpkptcFiKG",

  "__PowerAppsId__": "8IpkptcFiKG",

  "Attribute": "Months to Pay Back",

  "Output": "46.9"

}

Super User
Super User

Re: Advanced edit condition

@Caitlin_Knox1 

No worries at all.  This is a fun challenge and it feels like we can sort it out pretty quick.  I see you're using a variable for the 'eMail sent' check...is that on ALL of the paths?  If so, what do you think of this approach:

 

First, have a condition that checks the email sent.  If True, then probably a much shorter path, right?

 

If that value is False, then do a Compose which defines a "Path Label" depending on the Output value.  For this, I stole an old Excel trick and just nested a couple of IF statements.  There are probably more elegant ways, but this works so far.  The expression looks like this:

 

if(equals(less(float(outputs('Sample_Output')?['Output']),3),true),'Less3', if(equals(less(float(outputs('Sample_Output')?['Output']),6),true),'Less6','Great6'))

 

(If the output is less than 3, it labels it "Less3", if it's not, we look to see if it's less than 6, and if it's not, then we default to "It must be bigger than 6")

 

Then do a Switch on the path label, which will give you the ability to have more than two paths.  Here's what that looks like:

20191109a.PNG

 

Let me know if that helps.  Keep us posted.

 

-Ed-

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

 

Would I put the Path action here (see image with red arrow) IMAGE 

Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

dejavu

 

Same error message as before with the compose action

 

InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2039': 'The template language function 'float' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.

 

I did have to modify this formula to 

if(equals(less(float(outputs('Get_a_Row')?['Output']),3),true),'Less3', if(equals(less(float(outputs('Get_a_Row')?['Output']),6),true),'Less6','Great6'))

because I got an error message that 'Sample_Output' couldn't resolve to the template

current setup: screenshot 

I realize I can remove the conditions in each case, It just deletes all subsequent actions- So once I get it working, I will tidy it up and add the condition above the compose action as you suggested.

Super User
Super User

Re: Advanced edit condition

@Caitlin_Knox1 

Is the error showing on the updated/new Compose?  If you haven't deleted the older bits, I wonder if the error is just a remnant from that stuff.  Which step is highlighted on the error?  It looks like it's taken care of in the "current view" image, but I don't like to make too many assumptions.  Also, the sample data that you gave, was that from a run that errored out?  I'm wondering if there's a weird value in the Output column of the row you are selecting.

 

You are correct in the placement (red arrow)., and I think we're very close.

 

-Ed-

Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

Yes, its showing on the Compose action. The current view image shows the architecture when it failed on the compose action. What do you mean by deleting older bits? The only thing prior is an action to print an excel worksheet to pdf

 

screenshot 

 

also, here's an image of what the source table looks like. I have tried changing the data type to number, general, and text. All with the same error of being unable to process the template language  source table.PNG

Super User
Super User

Re: Advanced edit condition

"Older bits" was in reference to previous iterations of the flow build.  You got it cleared out, it looks like from the screenshot, but I was just making sure it wasn't erroring out on something old.

 

Ok, so now we want to see if the sample data you sent from the earlier post was from the same row.  Can you post the output from the Get a Row step if it's a different row?  Also, I haven't worked with spaces too much before...do we know if the underscores in the Get_a_row part are messing anything up?  If it's in the single quotes, they may not be necessary. I'll  try that real quick, as well.  - nm, I confirmed the underscores are ok.  🙂

Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

Here's the output, it is the same

 

{
"@odata.etag": "",
"ItemInternalId": "8IpkptcFiKG",
"__PowerAppsId__": "8IpkptcFiKG",
"Attribute": "Months to Pay Back",
"Output": "46.9"
}
 
Tried removing the _ and get this error: 
The template validation failed: 'The action(s) 'Get a Row' referenced by 'inputs' in action 'Compose' are not defined in the template.'.
 
I do think its required for the spaces
Super User
Super User

Re: Advanced edit condition

@Caitlin_Knox1 

Ya, I saw the underscores on my steps so now I know 🙂

 

So, I'm glad you posted a screenshot of the table.  Can we confirm that when you click on the value in the _PowerAppsID_ column, the Table name is the same as when you click on the corresponding Output value?  Check the "Design" tab, and the table name is in the upper left (see below):

 

20191109b.PNG

 

Part of me wonders if you've got two separate tables next to each other, and the Float() has no idea what 'Output' is since it's not in the same table.  Or you could have one table formatted weird.  But check the table name to be sure.  I mean, I can see "output" in the JSON, but just want to check all the angles, you know?

 

-Ed-

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

Yes, the table names are the same

Capture4.PNG

Super User
Super User

Re: Advanced edit condition

Ya, I knew it was a stretch...  Still looking at this, but try this while I'm building a table to match yours:

 

if(equals(less(float(string(outputs('Get_a_Row')?['Output'])),3),true),'Less3', if(equals(less(float(string(outputs('Get_a_Row')?['Output'])),6),true),'Less6','Great6'))

Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

Same error. I'm going to rebuild from scratch. There's got to be some change I made that Flow couldn't update or something that's corrupting it.

 

Capture.PNG

Super User
Super User

Re: Advanced edit condition

Really weird.  Ok, ya.  I'll hold off until I hear back.

Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

I am still going in circles here. I created a compeltely new excel file, new table- and ended up back to using the UI less than operators. This is the original reason why I pivoted to advanced condition but, I'd like to see if there's something I can do here in order to exhaust all the efforts in my head.

I've had to wrap my values in '' to get it to actually run successfully and I'm sure that is why now, the logic is not accurate. The Condition 2 is 'Greater than 3' AND 'Less than 6'. You can see the Output number is 46.9- so this condition result should be false.

I've tried it where the output value is under 3, and the first condition checks accurately that its true. BUt can't get the second condition to work for the different threshold

 

Capture.PNG

Highlighted
Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

***NEVERMIND*** no matter the value of the cell, it always goes to the last condition. So even for 1 or 4 from that ActualOutput field, its always rendering True for Greater than 6. Back to square one

 

I got this working. Still think it should have worked the other way you suggested, as logically it made more sense. I don't know, I wish someone from Flow could pipe in and explain it to us.

What ended up working is adding a Compose action as the first step in the Apply to Each. The value of the first Apply to Each is from the List rows present in a table, and the input for the Compose is the value from the Get a row action.

Then I used my original syntax but with 'Compose' instead as well as making them both string data types in my condition statement.

less(string('Compose'),string(3))
less(string('Compose'),string(6))
greater(string('Compose'),string(6))
 
Final Solution.PNG
 
Super User
Super User

Re: Advanced edit condition

That is absolutely bonkers.  How is Less even working when comparing to Strings?  Makes no sense to me.  I know that it's working, but agree it would be good to get official input.  @v-bacao-msft any thoughts?

 

-Ed-

 

Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

I am still looking for a solution here...any thoughts?

Caitlin_Knox1
Level: Powered On

Re: Advanced edit condition

I know you are all DYING to know the outcome lol. I am happy to report that I got this working. I put the logic in the Excel sheet that I was trying to use in Flow. The output of that was the text "Less3" "Less6" "Greater6" as suggested. I added this row to the Table, with its own special Power Apps ID to be used as dynamic content in my Flow. I like the Switch model the best, so that's what my production Flow uses.

Thanks again for all the help, this was a tricky one!

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,004)