cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Craig99b
New Member

Switch case error using a number

Hello,

 

I have a calculated value in a SharePoint list called DaysToClose that calcualtes the days remaining before a due date.  I want to notify the owner when an item is due in 5 days, 0 days, or less than 0 days.

 

I think I have it set up correctly but it gives me an error.

Capture.PNG

 

Below is the flow:

 

Capture2.PNG

 

Not quite sure what I have wrong here.  Seems simple enough.  Does it have something to do with 95.000000 vs 95?  But shouldn't it simply go to the default route since 95.0000000 doesn't equal 0?  Seems like a data type issue to me but I'm not sure how to fix it.

 

Thanks,

Craig

 

3 REPLIES 3
v-xida-msft
Community Support
Community Support

Hi @Craig99b,

 

Could you please share a full screenshot of your flow's configuration?

Could you please show a bit more about your SharePoint list?

 

I have created a SharePoint list on my side and the data structure of it as below:4.JPGNote: TaskName column is Single of line text type column, Executor column is a Single line of text type column, Due Date column is a Date type column and DaysToClose column is a Calculated type column. The DaysToClose column data structure as below:3.JPG

Within above formula box, type the following formula:

 

=ROUND([Due Date]-NOW(),0)

Date type returned from this formula set to Number.

 

 

I have made a test on my side and please take a try with following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a "Get items" action, specify Site Address and List Name.
  • Add a "Apply to each", input parameter set to output of "Get items" action.
  • Within "Apply to each", add a "Switch case" action. Within "Switch" action, On field set to following formula:

 

int(item()?['DaysToClose'])

 

Add two Case branches (Equals 0 and Equals 5). Within Case 0, Case 5 and Default branches, add a "Send an email" action separately.

 

Image reference:5.JPG6.JPG

The flow works successfully as below:7.JPG

 

 

Best regards,

Kris

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BharatMathur
Regular Visitor

I faced the same issue today and then got to this post. Was able to resolve it by converting the 'Switch On' dynamic value to int and then comparing it to multiple case values. Hope it helps.

Hi @v-xida-msft ,

How can we address negative, positive and 0 in a Switch statement?

Example:

  • If varNumber is negative do X
  • If varNumber is positive do Y
  • If varNumber = 0 do Z

Thank you

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Users online (29,483)