web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Convert values to spec...
Power Automate
Answered

Convert values to specific number format while generating CSV table

(0) ShareShare
ReportReport
Posted on by 8

Hello Everyone!

 

I am pretty new to this forum, and I need your help. I am building a flow to "convert" Excel xlsx file into csv file. The thing that I am struggling with is how to get specific number format for a column within csv file that I generate?

 

I am having an excel file on sharepoint with numbers like this:

Michal_O_0-1665736221438.png

and that's exactly the format I want to keep in my csv file. When I build my csv file "somehow" I get this:

Michal_O_1-1665736309418.png

 

So the space is removed and I only see a full number. I am not Power Automate expert and I am building majority of the stuff in "just build & try" way, and I tried to find a solution in google, and some other forums, and still can't get it work. If I would open the xlsx file in excel, and then save it as csv myself locally - I would get exactly what I need, but that's the case - I want it to be automated.

 

my flow looks like this:

Michal_O_2-1665736488557.png

And then of course create file action with output from Create CSV table

 

Column 15 is the one containing only numbers which I want to be in specific format when it's in CSV. 

 

Any help with this? Thank you!

Categories:
I have the same question (0)
  • v-bofeng-msft Profile Picture
    on at

    Hi @Michal_O ,

     

    Please try:

     

    formatNumber(item()['Column15'],'0 000')

     

    vbofengmsft_0-1665737303024.png

     

    Best Regards,

    Bof

     

  • Michal_O Profile Picture
    8 on at

    Hey @v-bofeng-msft, thanks for quick reply! Unfortunately it didn't work, as I get following error:

     

    The execution of template action 'Create_CSV_table' failed. The column values could not be evaluated: 'The template language function 'formatNumber' expects its first parameter to be an integer or a decimal number. The provided value is of type 'String'. Please see https://aka.ms/logicexpressions#FormatNumber for usage details.'.

     

    Which I don't entirely get as this is the output of Column15 values (which I added just to see what's in there):

    Michal_O_1-1665739223111.png

    Michal_O_0-1665739160189.png

     

     

     

     

     

     

     

     

     

    So I guess that when rows are listed, and I get values of column 15 - it's stored as string, and I just can't convert it to numbers? How it is that for some people doing exactly the same thing with

    formatNumber(item()['Column15'],'0 000')

     it works, and it's recognized as numebr and for me it's not...

     

    Is there anything else I can do to make these numbers and format it in the way I want?

  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    Hi @Michal_O ,

     

    Please try:

    formatNumber(int(item()['Column15']),'0 000')

     

    Best Regards,
    Bof

  • Michal_O Profile Picture
    8 on at

    @v-bofeng-msft - You are a star! Thanks for pointing the right direction :). I am almost getting what I wanted but there is just one more issue. To make it work better I used this expression:

     

    formatNumber(int(item()['Column15']),'# ###')
     
    When I open the CSV file in excel, I get what I wanted:
    Michal_O_0-1665742845583.png

    Seems to be ok, but when I open the file in text editor (like KED) to see CSV file structure I get this:

    Michal_O_2-1665742980793.png

    So when it's 4/5/6 digit number it's all good, but when it's less it seems it's putting an extra space at the begining of each number - what I don't want :/. The result which I need must look like this:

    Michal_O_3-1665743078252.png

    So I am almost there, but I need to get rid of this extra space " " from the begining of 3 digit numbers

     


     

  • Michal_O Profile Picture
    8 on at

    Ok, it seems that I got it working :). At least it seems so considering how numbers look like.

     

    So the expression I used is this:

    if(greater(length(item()['Column15']),3),formatNumber(int(item()['Column15']),'# ###'),formatNumber(int(item()['Column15']),'###'))

    Basically to check if vlaue is 3 (less than 1000) digits or less then format should be ###, if it's greater than 3 (more than 1000) then it should be # ###.

     

    Result in the file looks fine in both Excel & KED:

    Michal_O_0-1665748515243.png

    No not needed spaces or anything like this :).

     

    Thank you @v-bofeng-msft fot your help and pointing me into the right direction!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard