web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Power Automate Functio...
Power Automate
Suggested Answer

Power Automate Function with multiple cases

(2) ShareShare
ReportReport
Posted on by
 
 
 

I have a Power Automate use case where incoming emails are assigned a category based on the from, name of and # of attachments, and certain keywords in the email body/subject. I would like to store all the categorization logic in a single action/expression. The action would have its output a single string category value. For example, something like below (this would work in Power BI/DAX). There can be potentially hundreds of categories, each with their own unique logic . Is something like this possible? Or would I need to nest an insane amount of ifelse calls?

    SWITCH(TRUE,
or(and(contains(body,'abc'),contains(subject,'def')),hasattachment=True),
"Category 1",
and(contains(body,'def'),contains(subject,'def')),
"Category 2",
"Unknown"
)
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,429 Super User 2025 Season 2 on at
     
    Yes, you can there is a switch statement in power apps but that is in the App side.
     
    In Power Automate there is a Case Statement.. but it doesn't work exactly like what you want.
     
    That being said, you absolutely could build a compound If statement that would give you want you want.
     
    So yes, it's possible, fun... no. possibly yes.
     
    If this answers your question I'd be grateful if you marked it as such and maybe a like :-)
     
    Cheers
     
     
  • Suggested answer
    ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    Create a table in SharePoint or Dataverse with columns containing the configuration that you are checking for and the necessary values to facilitate any instructions.
     
    You would just lookup the values in the table (if the category is set based on from, name and number of attachments) or loop through the table (if the category is set on checking things like the body contains 'abc' and the subject contains 'def').
     
    No need to create a complex If statement.
  • Michael E. Gernaey Profile Picture
    53,429 Super User 2025 Season 2 on at
     
    Please share an example so they can do it so they can mimic it. They gave an example of exactly what they need so share an example please so they can get it going :)

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard