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 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,969 Moderator 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,862 Moderator 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,969 Moderator 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 605

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard