cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

I need help understanding this power automate expression code

Hi all, I appreciate your time and involvement in this community. Thank you.

 

I need some help understanding some code my boss wrote in power automate. He used this expression to set a Variable we are using to calculate a forecast.

 

if(
    equals(
        outputs('Get_Permit')?['body/osp_undergroundfootageplannedft'],
        null
    ),
    0,
    if(
        equals(
            mod(
                int(outputs('Get_Permit')?['body/osp_undergroundfootageplannedft']),
                5000
            ),
            0
        ),
        div(
            int(outputs('Get_Permit')?['body/osp_undergroundfootageplannedft']),
            5000
        ),
        add(
            int(
                div(
                    int(outputs('Get_Permit')?['body/osp_undergroundfootageplannedft']),
                    5000
                )
            ),
            1
        )
    )
)

I think the first part means "if the outputs are null then do nothing. 

I think the second part is converting to integer so the math operators are satisfied with their data type. After that I need the help. I think it means we are taking the footage outputs and dividing it by 5000 and considering the remainder. If the answer isn't zero then we take the footage and divide by 5000. Whatever that number is gets added to 1?  Man, that can't be right. I would really love someone to put this in plain english. 

-PowerPlatguy

1 REPLY 1
abm
Super User
Super User

If the answer is zero then its divide by 5000 else add 1 to div by 5000. That's what that logic says. In other words if the number is not zero then add 1 to div by 5000. What's this formula trying to do? 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,317)