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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
AragakiSora
Frequent Visitor

Change Data Type for Specific Rows

Hi!

I have a table that looks similar to this: 

Issue_NameModuleThreshold_CriticalThreshold_SevereThreshold_Normal
Number Change120.0%10.0%NA
Number Change20.0%NANA
Number Change3-5.0%-10.0%NA
Number Change4-20.0%-15.0%NA
Number Change50.0%NANA
Number Change60.0%NANA
Number Change7-65.0%-70.0%-75.0%
Number Change8-95.0%-90.0%-85.0%
Number Change90.0%NANA
Number Change100.0%NANA
Number Change110.0%NANA
Number Change120.0%NANA
Corrupted Record11053
Corrupted Record231NA
Corrupted Record331NA
Corrupted Record431NA
Corrupted Record531NA
Corrupted Record631NA

 

When I connected the table to Power BI, the percentages are automatically transformed into decimals. I tried to recover the percentages by changing data type for the three columns, but the issue is that I don't want the thresholds for "Corrupted Record" to be transformed into percentages. 

 

This is how the table looks like in Query Editor: 

AragakiSora_0-1697125676237.png

 

I am wondering if it is possible to change data type for a few rows or if there is any workarounds.

Thank you in advance!

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

I suggest that you use this M code to transform your data as shown in the image below

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Replaced Value" = Table.ReplaceValue(Source,"NA",null,Replacer.ReplaceValue,{"Threshold_Critical", "Threshold_Severe", "Threshold_Normal"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"Issue_Name", "Module"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Issue_Name]), "Issue_Name", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Pivoted Column",{{"Number Change", Percentage.Type}, {"Corrupted Record", type number}})
in
    #"Changed Type"

Hope this helps.

Ashish_Mathur_0-1697252241729.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

I suggest that you use this M code to transform your data as shown in the image below

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Replaced Value" = Table.ReplaceValue(Source,"NA",null,Replacer.ReplaceValue,{"Threshold_Critical", "Threshold_Severe", "Threshold_Normal"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"Issue_Name", "Module"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Issue_Name]), "Issue_Name", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Pivoted Column",{{"Number Change", Percentage.Type}, {"Corrupted Record", type number}})
in
    #"Changed Type"

Hope this helps.

Ashish_Mathur_0-1697252241729.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Data types cover the entire column. Your only options are to set everything to text, or to leave it at variant (ABC123).

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.