Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
MAIK2705
Regular Visitor

data converted automatically to decimal numbers

Hi everyone,

 

I'm struggling with an issue in Power BI where  percentages are automatcally recognized as a decimal values. This is the data table

FundId2023-012023-022023-032023-042023-052023-062023-072023-082023-092023-102023-112023-122024-012024-022024-03
FS0000165,30%-10,60%18,70%-24,00%56,20%-5,30%-8,70%-20,70%0,00%0,00%0,00%0,00%0,00%0,00%0,00%
FS000028,80%-18,50%0,30%0,30%-7,70%-1,90%3,10%-1,10%-12,80%-21,10%14,40%0,00%0,00%0,00%0,00%
FS0000336,40%-28,70%7,40%-15,60%-25,40%7,80%32,40%-27,60%-10,00%-11,70%0,60%-10,70%-28,90%18,30%4,20%
FS0000430,70%-37,40%12,80%-31,40%-30,30%17,10%55,70%-29,80%-13,80%-16,80%16,90%-11,00%-37,10%23,40%7,80%
FS0000538,80%-26,30%-0,20%9,60%-20,10%28,70%8,40%11,10%-28,30%-3,00%-35,80%0,00%0,00%0,00%0,00%
FS0000614,80%-14,20%20,40%-0,10%-2,00%-9,70%4,70%-3,30%-12,40%22,10%3,20%1,20%-3,80%0,50%26,90%

 

The original data is in decimal format (e.g., 0.008 = 0.8%) but i convert it to percentage. However, when I import the Excel file into Power BI, the values are automatically converted to decimal numbers again.

 

The problem is that when I try to transform the decimal numbers to percentages using Power Query, it works initially (on power query view), but the format is lost when I charge the file. The only way I've found to maintain the percentage format is table view > column tools > format > percentage, but this is not a scalable solution since I have many columns to convert.

I've tried various methods to fix this issue, but none have worked so far. I'm looking for a solution that addresses the root cause of the problem, rather than just applying a workaround.

 

I put screenshot of the process:

1st : upload the file (which already changes the data type)

1.inital charge.jpg

2nd : the file in power query

2.power query.jpg

 

3rd: After transforming all the columns to percentages in power query looks fine.

3.power query change data type.jpg

 

 

4th: when i save and close power query everything gets wrong again 

4.wrong type of data charged.jpg

 

 

Can anyone help me resolve this issue?

 

Thank you very much in advance.

 

 

  

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @MAIK2705 ,

 

This can be resolved by following a couple of best-practice guidelines:

 

1) Structure your data correctly for reporting (normalisation):

After your navigation step, select your [FundId] column and go to the Transform tab > Unpivot Column (dropdown) > Unpivot Other Columns.

You will now have a normalised fact table structure with an [Attribute] and [Value] column.

You can change the names of these if you want by amending the code that has been created in the formula bar:

 

BA_Pete_0-1715081073068.png

BA_Pete_1-1715081199360.png

 

At this point, you can just change the Data Type of the new [Attribute] and [Value] columns. This will always work as you're no longer hard-coding specific column names into the transformation code.

 

2) Type your data correctly (standard data types):

Do not use the percentage data type in Power Query. It's just a mask over a Decimal type anyway. Change your new [Value] column to Decimal type and adjust the format under MEasure Tools in the Report View:

 

BA_Pete_2-1715081498723.png

 

BA_Pete_3-1715081557558.png

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

6 REPLIES 6
watkinnc
Super User
Super User

What I'm saying is that if this month, you load and format a column named March 24 to Excel, and then next month load Apr 24 to excel in place of March 24 column, that new column name will not be formatted even though it's in the same place, because Excel formatting is based on the column name, not the cell location. 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
watkinnc
Super User
Super User

The root cause is that your column names change, so Excel doesn't keep the formatting because there are new column names. Before loading to Excel, demote the headers, then change your column types. Yes, your columns will be named Column1, Column2, etc, but your data will remain typed, and you can always hide the first row in Excel.

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Hi watkinnc and thanks for the help,

 

However this is not the cause because is not only Excel, i tried uploading the data in CSV, with Gateway and MySQL and i have the same prob always. After formatting in power query its converted. 

 

Thanks

BA_Pete
Super User
Super User

Hi @MAIK2705 ,

 

This can be resolved by following a couple of best-practice guidelines:

 

1) Structure your data correctly for reporting (normalisation):

After your navigation step, select your [FundId] column and go to the Transform tab > Unpivot Column (dropdown) > Unpivot Other Columns.

You will now have a normalised fact table structure with an [Attribute] and [Value] column.

You can change the names of these if you want by amending the code that has been created in the formula bar:

 

BA_Pete_0-1715081073068.png

BA_Pete_1-1715081199360.png

 

At this point, you can just change the Data Type of the new [Attribute] and [Value] columns. This will always work as you're no longer hard-coding specific column names into the transformation code.

 

2) Type your data correctly (standard data types):

Do not use the percentage data type in Power Query. It's just a mask over a Decimal type anyway. Change your new [Value] column to Decimal type and adjust the format under MEasure Tools in the Report View:

 

BA_Pete_2-1715081498723.png

 

BA_Pete_3-1715081557558.png

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi BA_Pete and thanks for the answer,

 

1- I know maybe is not the most apropiate structure, and maybe i should normalise. Nevertheless, this table was just a sample, usually i have less columns FundID, Total Ret YTD, Total Ret 1Y, Total Ret 3Y and Total Ret 5Y, management fees etc...

That's why I thought normalising this type of data wasnt  a priority because in this performance table i dont use dates and other reasson is that if i unpivot around 40k differents rows this could affect the performance of the report. Im wrong or i should normalize it ?

 

2- I knew this way and following the approach of unpivot tables make sense, but imagine that one day i have lots of columns with % types and i should do it one by one . I think is not optimal.

 

However, i think what you said is the reasson "Do not use the percentage data type in Power Query. It's just a mask over a Decimal type anyway. " but anyway I think this is something which should be corrected. 

 

I think i will go for you second approach and hope not having lots of columns to change one day .

 

Thank you vey mach for the help.

Hi @MAIK2705 ,

 

My options 1) and 2) weren't really either/or, I recommend you do them BOTH.

 

1) Yes, unpivoting can be resource-intensive (as the whole table has to be loaded into memory) and may affect refresh speed but, as you get into using Power BI more, you'll see that normalised data makes everything else much easier once done. Power BI can compress data orders of magnitude more efficiently once it's normalised (so the PBIX file is much smaller and faster to publish etc.), relationships can be made between normalised tables far more intuitively, and FAR fewer measures have to be written.

 

2) This is another reason why you normalise the structure first where possible: so you only need to change the Type of your [Value] column. However, if you do have columns that logically need to stay as their own columns, then you can multi-select them (Ctrl+click or Click Shift+click), right-click on one of the selected columns title, go to Change Types and select a type to change ALL the currently selected columns. This makes bulk type changes very fast, just be mindful that the column names will now be hard-coded into the transformation.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors