Forum Discussion

Sab's avatar
Sab
Helper V
5 years ago
Solved

Error converting percentages

Hello

 

as you see in the screeshot below, when I load these percentage data, the negative ones stay as Text and I don't know why!!! I cannot convert them to number. There is no Chnage Type step in the query and I disabled automatic detection of data types..

 

 

Thank you!

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Your column is not converted to a number type, it's still type any. As long as you have the header row in your data instead of promoting  them to headers. Ideally you'd format the Excel data as a table, and then no work would even be necessary, except to click the Get Data From Table/Range button.

    Once you Promote those headers, you can probably use:

    Fixed = Table.TransformColumns(PriorStep,  {{"Premium % Change", Number.FromText}})

     

    --Nate

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Your column is not converted to a number type, it's still type any. As long as you have the header row in your data instead of promoting  them to headers. Ideally you'd format the Excel data as a table, and then no work would even be necessary, except to click the Get Data From Table/Range button.

    Once you Promote those headers, you can probably use:

    Fixed = Table.TransformColumns(PriorStep,  {{"Premium % Change", Number.FromText}})

     

    --Nate

  • Sab 

    Try to right-click on the column, Change Type, and select Percentage.

    If this doesn't solve your problem, can you share the M code or explain how the column was built? Check source data as well

    • Sab's avatar
      Sab
      Helper V

      Not many steps at all! It just read the excel, navigate to the sheets and then converts positive percentages correctly, but it does not the negative ones!!!

       

      I tried to change the '-' and the '%' with regular characters but nothing happened!

       

      So the correct change type step (which I don't know where is executed!!!), for the first negative value of -0.3% should have been converted to -0.003