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 / Convert a number to a ...
Power Automate
Suggested Answer

Convert a number to a variable based on a range

(0) ShareShare
ReportReport
Posted on by 30
My flow gets data and one piece that is needed comes in a number format which we need to convert to group to make it readable to the end user. The data can come in as an integer 1-360 and then that needs to be converted to a group. Example
 
1-15 = Group A
16-30 = Group B
and so on. 
 
I do not want to have a switch with 300+ options.
Categories:
I have the same question (0)
  • Suggested answer
    Mark Nanneman Profile Picture
    991 Moderator on at
    There are a few ways to handle this.  First thing I'd ask is if your "Groups" exist in any database?  For example is there a SharePoint list for "Group A", "Group B" etc?  Is there a dataverse table?


    Method 1: Filter a List in SharePoint or Dataverse

    I'd recommend creating a data source you can use in SharePoint or Dataverse or even an excel file.
     
    Easiest method migth be to just use a sharepoint list.

    - Create a "Groups" list with all your groups and add a max number and a min number column.
    - In power automate just query the SharePoint list and filter if your number is >= the min number field and <= the max number field.  In the Odata filter it'd look something like "minNumberField <= @{<your number value>} and maxNumberField >= @{<your number value>}"

    -This will output the record with the "Group" name you want.

    you could use excel to create the number ranges by selecting and dragging down--as along as you select more than two rows it'll do the math for you.



    (P.S.) you could even skip the "Min" column and just use max as long as you sort your Groups by the Max number ascending.

    Then you filter on all rows that have a Max greater than or equal to your flow's current number, and then use the first record returned.

    Method 2: Filter an array built into your flow

    You could build a simple array in your flow using a "Compose" action.

    You'de write something like this in your compose:

    [
    {"name": "Group A",
    "min": 1,
    "max":15},
    {"name": "Group B",
    "min": 16,
    "max":30},
    ...
    ]

    Then you can use a filter action on that compose action.

    Hope that helps/makes sense.
  • Tiago Gouveia Profile Picture
    2 on at
    The Method 2 from @Mark response will  be excellent for the scenario you described.
    In order to make the solution a bit more dynamic and not use the lists from Method 1, I would suggest placing the array described in Method 2 into an environment variable. 
    You can put the Json Value
    [
        {
            "name": "Group A",
            "min": 1,
            "max": 15
        },
        {
            "name": "Group B",
            "min": 16,
            "max": 30
        }
    ]
    in a Environment Variable and in future dont need to update your flow. In you need more Groups ranges, only need to update the Environment Variable.

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!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 250 Super User 2026 Season 1

#2
Expiscornovus Profile Picture

Expiscornovus 222 Most Valuable Professional

#3
Haque Profile Picture

Haque 174

Last 30 days Overall leaderboard