cancel
Showing results for
Did you mean:
New Member

## Rounding up to 15

Hi!

I have been searching the forum, but I can't get to an answer that works.

My flow receives a bunch of parameters, which are slightly modified by the flow, and then passed into API using HTTP request / POST.

• The API requires one of the parameters to be in 15 minute increments.
• The parameter that I start off with, is received in the flow as an integer bigger than zero (0).
• I'm trying to modify this integer, by rounding it upwards.

Input 1 to 15, should be 15

Input 16 to 30, should be 30

Input 31 to 45, should be 45

etc.

I've been at it for 2+ hours, trying to figure out a Compose expression that works, but I'm stuck.
If you have any thoughts, you will be my hero.

Cheers!

1 ACCEPTED SOLUTION

Accepted Solutions

It's not pretty, but this formula will get you what' you're looking for:

``````mul(
if(
equals(
int(
last(
split(
formatNumber(
div(
float(
item()
),
float(
15
)
),
'0.0'
),
'.'
)
)
),
0
),
int(
formatNumber(
div(
float(
item()
),
float(
15
)
),
'0'
)
),
int(
first(
split(
formatNumber(
div(
float(
item()
),
float(
15
)
),
'0.0'
),
'.'
)
)
),
1
)
),
15
)``````

The above is a brute-force way of implementing what's known as a 'Ceiling' function which rounds up to the nearest selected significance (in your case, 15).

You should be able to replace every instance of '15' with another whole-number significance (ie: 5) and it'd work just as well.

Also - although you didn't ask for it - just to show how much easier this is in Power Fx, here's the above functionality but implemented in Power Apps:

``````\$"{ThisItem.Value} => {With(
{
// The value you want to round //
number: ThisItem.Value,
// The multiple to which you want to round.
significance: 15
},
RoundUp(
number / significance,
0
) * significance
)}"``````

Which results in the following:

Cheers!

5 REPLIES 5
Super User

Hello, @RvdK , try to use this expression accordingly:

``````if(And(lessOrEquals(triggerBody()['number'],15),greater(triggerBody()['number'],0)),15,
if(And(lessOrEquals(triggerBody()['number'],30),greater(triggerBody()['number'],15)),30,
if(And(lessOrEquals(triggerBody()['number'],45),greater(triggerBody()['number'],30)),45,0)))``````

 If my reply helped you, please give a 👍 , & if it solved your issue, please 👍 & Accept it as the Solution to help other community members find it more. I am primarily available on weekdays from 6-10 PM CT and 5-10 PM CT on weekends. Visit my Blog: www.powerplatformplace.com

New Member

Hi!
Thanks for giving that a shot, really much appreciated!

That appears to do the trick up until 45, but I'm afraid that I don't have a cap on the value.
The biggest what I've seen would be under a value close to a thousand.

Yes, I could technically keep on expanding what you wrote there, but I would want to keep an open mind that this value can go anywhere.

I had figured something along the line of:

``````div(triggerBody()['number'],15) # this would become a number that needs to be rounded
float() # to show the two digits behind the dot / comma.
split() # to return these characters``````

This gets me quite far, but only works IF the number is not a rounded number.

New Member

I found my own answer, which works beautifully, without too many difficult calculations.
Some of you might not like this solution as it takes 5 steps instead of one compose, but..

Beauty of this one is that the input doesn't matter. This scales endlessly.

``````input
1: initialize var1 - int: div(input,15)
2: initialize var2 - int: mod(input,15)
3: initialize var3 - int:
4: compose: greaterorequals(step2,1)
5: condition: output(step4) is equal to true()
if no: set var3: mul(step1,15)``````

It's not pretty, but this formula will get you what' you're looking for:

``````mul(
if(
equals(
int(
last(
split(
formatNumber(
div(
float(
item()
),
float(
15
)
),
'0.0'
),
'.'
)
)
),
0
),
int(
formatNumber(
div(
float(
item()
),
float(
15
)
),
'0'
)
),
int(
first(
split(
formatNumber(
div(
float(
item()
),
float(
15
)
),
'0.0'
),
'.'
)
)
),
1
)
),
15
)``````

The above is a brute-force way of implementing what's known as a 'Ceiling' function which rounds up to the nearest selected significance (in your case, 15).

You should be able to replace every instance of '15' with another whole-number significance (ie: 5) and it'd work just as well.

Also - although you didn't ask for it - just to show how much easier this is in Power Fx, here's the above functionality but implemented in Power Apps:

``````\$"{ThisItem.Value} => {With(
{
// The value you want to round //
number: ThisItem.Value,
// The multiple to which you want to round.
significance: 15
},
RoundUp(
number / significance,
0
) * significance
)}"``````

Which results in the following:

Cheers!

New Member

Thanks, I will give this a shot.

Announcements

#### December 2023 User Group Update: Welcoming New Groups and Upcoming Events

A new month means it's time to celebrate and welcome the new user groups that have joined our community. We are excited to announce that we have more than 8 New Groups, which is no surprise after the amazing Microsoft Power Platform Conference. This month, we are breaking them out by the different community categories. If your group is listed here, give this post a kudo so we can celebrate with you! Don't forget to take a look at the many events happening near you or virtually! It's a great time of year to connect and engage with User Groups both locally and online.   Please Welcome Our NEW User Groups   Power Platform: PowerIT User Group: Nottingham Power Platform User Group: Bergen Power Platform User Group: Danmark Nashville Power Platform User Group Microsoft Ambassador Program y Mujer Latina Technolochicas NCWIT Community Copilot Studio:  Copilot User Group Italia Dynamics365: Dynamics User Group AdriaticDynamic 365 Azerbaijan   December User Group Events   01 Dec 2023 Aprendiendo Desarrollo web, creando mi primer power app y power page. 01 Dec 2023 Q4 Hybrid Philadelphia Dynamics 365 & Power Platform User Group Meeting05 Dec 2023APAC Dynamics 365 FastTrack Bootcamp - BI and Analytics07 Dec 2023Bay Area Power Platform Meetup: Learn, Share, and Connect07 Dec 2023Indiana D365/AX December User Group Meeting07 Dec 2023Dynamics User Group Meeting: Houston09 Dec 2023 December '23 - NEW Power Apps User Group Meeting - Online 12 Dec 2023December Cleveland Power Platform User Group Meeting12 Dec 2023 RW2 Data Stewardship Open Forum Discussion 13 Dec 2023  Black Country Power Platform User Group - December 2023 - West Midlands

Welcome to our November Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members. If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across the Power Platform and beyond.        This month's highlights:- - Our most active community members- Microsoft Power Up Program- Microsoft Community Days website - The latest blogs and more                 COMMUNITY HIGHLIGHTS Check out the most active community members of the last month. These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, just get active! FLMikePstork1Nived_NambiarWarrenBelzSprongYeManishSolankiLaurensMwskinnermlcAgniusExpiscornovuscreativeopinion KatieAUinzil2kHaressh2728hafizsultan242douicmccaughanwoLucas001domliu   Power Up Program Click the image below to discover more about the amazing Microsoft Power Up Program, as Reem Omar, Abbas Godhrawala, Chahine Atallah, Ruby Ruiz Brown, Juan Francisco Sánchez Enciso, Joscelyne Andrade Arévalo, Eric G. and Paulina Pałczyńska share how non-tech professionals can successfully advance into a new career path using Microsoft #PowerPlatform.   To find out more about this amazing initiative, click here to apply for the program and reboot your journey into low-code app development today!     Community Days - Event Website Have you checked out the Community Days website yet? Dedicated to the volunteer community organizers around the world, Community Days is the perfect place to find an event near you or add an event for wider exposure. Many thanks to Thomas Daly, Sharon Weaver, Sedat Tum, Jonathan Weaver, Manpreet Singh, David Leveille, Jason Rivera, Mike Maadarani, Rob Windsor and the team for all their hard work. Anyone can host a Community Day on any topic relevant to our industry, just click the image below to find out more.       EVENT NEWS Power Platform French Summit - Paris/Virtual - 6-7th Dec It's not long now until the Power Platform French Summit, which takes place both virtually and in-person at the Microsoft France conference center in Paris on 6-7th December 2023. If you can't make it in-person, all sessions will also be broadcast on virtual networks for better distribution and accessibility.   There's a fantastic array of speakers, including Jérémy LAPLAINE, Amira Beldjilali, Rémi Chambard, Erika Beaumier, Makenson Frena, Assia Boutera, Elliott Pierret, Clothilde Facon, Gilles Pommier, Marie Aubert, Antoine Herbosa, Chloé Moreau, Raphaël Senis, Rym Ben Hamida, Loïc Cimon, Joséphine Salafia, David Zoonekyndt, Aïcha Charpentier, Henry Jammes, Milene Rochard, Mehdi EL YASSIR, and many more. Click the image below for more information.       LATEST COMMUNITY BLOG ARTICLES Power Apps Community Blog Power Automate Community Blog Copilot Community Blog Power Pages Community Blog

#### Unlocking the Power of Community: A Journey with Featured User Group leaders Geetha Sivasailam and Ben McMann

In the bustling world of technology, two dynamic leaders, Geetha Sivasailam and Ben McMann, have been at the forefront, steering the ship of the Dallas Fort Worth Power Platform User Group since its inception in February 2019. As Practice Lead (Power Platform | Fusion Dev) at Lantern, Geetha brings a wealth of consulting experience, while Ben, a key member of the Studio Leadership team at Lantern, specializes in crafting strategies that leverage Microsoft digital technologies to transform business models.   Empowering Through Community Leadership Geetha and Ben's journey as user group leaders began with a simple yet powerful goal: to create a space where individuals across the DFW area could connect, grow their skills, and add value to their businesses through the Power Platform. The platform, known for its versatility, allows users to achieve more with less code and foster creativity.   The Power of Community Impact Reflecting on their experiences, Geetha and Ben emphasize the profound impact that community engagement has had on both their professional and personal lives. The Power Platform community, they note, is a wellspring of resources and opportunities, fostering continuous learning, skill enhancement, and networking with industry experts and peers.   Favorite Moments and Words of Wisdom The duo's favorite aspect of leading the user group lies in witnessing the transformative projects and innovations community members create with the Power Platform. Their advice to aspiring user group leaders? "Encourage diverse perspectives, maintain an open space for idea-sharing, stay curious, and, most importantly, have fun building a vibrant community."   Building Bridges, Breaking Barriers Geetha and Ben encourage others to step into the realm of user group leadership, citing the rewarding experience of creating and nurturing a community of like-minded individuals. They highlight the chance to influence, impact, and positively guide others, fostering connections that extend beyond mere technology discussions.   Joining a User Group: A Gateway to Growth The leaders stress the importance of joining a user group, emphasizing exposure to diverse perspectives, solutions, and career growth opportunities within the Power Platform community. "Being part of such a group provides a supportive environment for seeking advice, sharing experiences, and navigating challenges."   A Year of Milestones Looking back at the past year, Geetha and Ben express pride in the group's growth and global participation. They recount the enriching experience of meeting members in person at the Microsoft Power Platform conference, showcasing the diverse range of perspectives and guest speakers that enriched the community's overall experience.   Continuous Learning on the Leadership Journey As user group leaders, Geetha and Ben recognize the continuous learning curve, blending interpersonal skills, adaptability, and dedication to foster a vibrant community. They highlight the importance of patience, persistence, and flexibility in achieving group goals, noting the significance of listening to the needs and suggestions of group members.They invite all tech enthusiasts to join the Dallas Fort Worth Power Platform User Group, a thriving hub where the power of community propels individuals to new heights in the dynamic realm of technology.