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 Apps
Answered

Rounding up to 15

(0) ShareShare
ReportReport
Posted on by 10

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!

Categories:
  • AhmedSalih Profile Picture
    6,680 Moderator on at

    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


     

     

  • RvdK Profile Picture
    10 on at

    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.

  • RvdK Profile Picture
    10 on at

    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 yes: set var3: add(mul(step1,15)15)
    if no: set var3: mul(step1,15)

     

  • Verified answer
    ohthreesixtyfive Profile Picture
    39 on at

    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'
    			)
    		),
    		add(
    			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.

     

    ohthreesixtyfiv_0-1662153082149.png

     

    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:

     

    ohthreesixtyfiv_1-1662153331053.png

     

    Cheers!

  • RvdK Profile Picture
    10 on at

    Thanks, I will give this a shot.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 239

Last 30 days Overall leaderboard