Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

How do I change duration (minutes) to Duration (text) using power automate select?

Posted on by 14

Hello, I'm relatively new to Power automate so please excuse me if this has already been asked.

 

I'm generating a report from a SharePoint list which contains booking information. What I want to achieve is to automatically swap out the duration values for text. 

My current Setup is this:
Power apps trigger -> Get Items -> Select (pictured below) -> Create CSV Table -> into file (Pictured below)-> into email (finish)

thughes1_0-1710167312346.png 

Which produces the following output : 

thughes1_1-1710167360220.png

What I would like to achieve is for the flow to automatically swap "30" -> "30 Minutes", "60" -> "1 hour" etc etc...

As this is a fantastic product I know this can be achieved somehow, its just that I've not quite learned how to effectively search these forums for specific requests such as this.

 

 

  • Andrew_J Profile Picture
    Andrew_J 1,962 on at
    Re: How do I change duration (minutes) to Duration (text) using power automate select?

    @thughes1 

     

    So you will edit your SP list, then when an item is created or modified, it will be get items then through the paralle branch, 16 number, this would update the number to text values.  These 16 branches would then common up with select in which would would use the text version of the time.  Once the data has been selected then create your CSV file and send.  Flow ends.

     

    Or at least that is what I think you want.

     

    Andrew

     

     

  • Andrew_J Profile Picture
    Andrew_J 1,962 on at
    Re: How do I change duration (minutes) to Duration (text) using power automate select?

    @thughes1 

     

    I think the minutes colum in your sp list is a number field and you want it to be in text so that is why I suggested you use the 16 branches to write the text data indvidually into a new time column as text.  Then use the text in the select to output the CSV.

     

    However I could be wrong.

     

    Andrew

  • TH-27111330-0 Profile Picture
    TH-27111330-0 14 on at
    Re: How do I change duration (minutes) to Duration (text) using power automate select?

    Just to further on the above, the column where the information is being pulled from is formatted as a number

    thughes1_0-1710173479094.png

     

  • TH-27111330-0 Profile Picture
    TH-27111330-0 14 on at
    Re: How do I change duration (minutes) to Duration (text) using power automate select?

    Hi Both,

     

    Really appreciate the rapid replies from both of you. Andrew I was in the process of getting more information for you just when i saw happy's response so I figured I'd better test that quickly. 

    @happyume  I've given that a go, the formula I used was the following: 

    concat(int(div(item()?['Duration'], 60)), ' hours and ', int(mod(item()?['Duration'], 60)), ' minutes'
    Which returned the following error.
    The execution of template action 'Select' failed: The evaluation of 'query' action 'where' expression '{
    "Title": "@{item()?['Title']}",
    "MeetingStart": "@{formatDateTime(item()?['MeetingStart'],'M/dd/yyyy h:mm tt')}",
    "Duration": "@{concat(int(div(item()?['Duration'], 60)), ' hours and ', int(mod(item()?['Duration'], 60)), ' minutes') }",
    "Room Count": "@{item()?['RoomCount']}",
    "Created By": "@{item()?['Editor']?['Email']}",
    "Cost-Code": "@{item()?['Cost_x002d_Code_x002d_2/Value']}",
    "Room Name": "@{item()?['RoomName']}",
    "Approved By": "@{item()?['Approver']}",
    "Booking ID": "@{item()?['ID']}"
    }' failed: 'The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.


    Any ideas?

  • Mitanshu Profile Picture
    Mitanshu 1,584 on at
    Re: How do I change duration (minutes) to Duration (text) using power automate select?

     

    concat(int(div(outputs('Compose'), 60)), ' hours and ', int(mod(outputs('Compose'), 60)), ' minutes') 

     

    You can use above expression to convert your duration into format x hours and y minutes

     

    div(outputs('Compose'), 60) is giving the hour component
    mod(outputs('Compose'), 60) is giving the minute component

     

    You will have to replace outputs('Compose') with your item()?['Duration'] or equivalent

     

    If you don't want 0 hours and to show up for cases where Duration is less than 60, you can always use a condition to check, something like if(outputs('Compose') >= 60

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If this post or my previous reply was useful in other ways, please consider giving it Thumbs Up.

     

     

     

  • Andrew_J Profile Picture
    Andrew_J 1,962 on at
    Re: How do I change duration (minutes) to Duration (text) using power automate select?

    @thughes1 

     

    The way I would do it is to have a number of paralle branches based on the duration and then add a seperate column for duration in text.  Therefore if 30 was entered, this would go down the 30 branch and then add the 30 minutes in the text field.  Once you have the 30 minutes and say 60 minutes working you can then go and add the rest.  However there will be a limit as to how many branches you can have so assuming an 8 hour day in 30 minutes booking interval that would require 16 branches. 

     

    However reading your question above, I am not sure the above logic will help you.  It would be good to understand the full process as I am assuming you are modifing a list initialy but I feel that you do not want an email for every change.

     

    Let me know what you think.

     

    Regards,

     

    Andrew

     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,532

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,050

Leaderboard