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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to transform a number into a percentage without using the format func.

I´ve been strugguling for the past days and I can't find the answer anywhere.

on my p&L table I have a color format that if the value is below 0 then is red otherwise is blue. 
Now when I change the number values into percentage then it convert it to string values which causes that my actual color:

Actual Color = IF([Actual]>=0.0,"#118DFF",IF([Actual]<0.0, "#D64550"))
 
Makes them blue which makes sense beacuse then again is not a value is a string.
In the column is a mix between numbers and percentages so the code is as following to calculate the percentages and get the color right.
 
Actual = VAR var1 = IF(HASONEVALUE('Sort Account Type'[Account_Type]),
VALUES('Sort Account Type'[Account_Type]),BLANK())
return
SWITCH(var1,
"Margin Sales New",if([Margin Sales New]<> BLANK(),CONVERT([Margin Sales New], DOUBLE)*100,BLANK()),
"Margin Sales Used Direct",if([Margin Sales Used Direct]<> BLANK(),CONVERT([Margin Sales Used Direct],DOUBLE)*100 ,BLANK()),
"Margin Sales Used RV",if([Margin Sales Used RV]<> BLANK(),CONVERT([Margin Sales Used RV],DOUBLE)*100,BLANK()),
"Margin Rental incl Dep.",if([Margin Rental incl Dep.]<> BLANK(),CONVERT([Margin Rental incl Dep.],DOUBLE)*100,BLANK()),
"Margin Lease incl Dep.",if([Margin Lease incl Dep.]<> BLANK(),CONVERT([Margin Lease incl Dep.],DOUBLE)*100,BLANK()),
"Margin Damage",if([Margin Damage]<> BLANK(),CONVERT([Margin Damage],DOUBLE)*100,BLANK()),
"Margin Sales Parts",if([Margin Sales Parts]<> BLANK(),CONVERT([Margin Sales Parts],DOUBLE)*100,BLANK()),
"Margin Transport",if([Margin Transport]<> BLANK(),CONVERT([Margin Transport],DOUBLE)*100,BLANK()),
"Net Gross Margin",if([Margin]<> BLANK(),CONVERT([Margin],DOUBLE)*100,BLANK()),
"Gross Profit",[Gross Profit],SUM('P&L'[KUSD]))
 
BUT THE PERCENTAGE SIGN DOES NOT APPEAR ON THE CELL AND I WANT TO KNOW HOW.
Captura de pantalla 2023-03-09 085954.png
 
Pls Help 😣
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks @ppm1 & @amitchandak  for your replies.

The soltion that I found was as following:

Actual = VAR var1 = IF(HASONEVALUE('Sort Account Type'[Account_Type]),VALUES('Sort Account Type'[Account_Type]),BLANK())
RETURN
SWITCH(var1,
"Margin Sales New",IF([Margin Sales New]<>BLANK(), FORMAT([Margin Sales New], "0.0%"), BLANK()),
"Margin Sales Used Direct",IF([Margin Sales Used Direct]<>BLANK(), FORMAT([Margin Sales Used Direct], "0.0%"), BLANK()),
"Margin Sales Used RV",IF([Margin Sales Used RV]<>BLANK(), FORMAT([Margin Sales Used RV], "0.0%"), BLANK()),
"Margin Rental incl Dep.",IF([Margin Rental incl Dep.]<>BLANK(), FORMAT([Margin Rental incl Dep.], "0.0%"), BLANK()),
"Margin Lease incl Dep.",IF([Margin Lease incl Dep.]<>BLANK(), FORMAT([Margin Lease incl Dep.], "0.0%"), BLANK()),
"Margin Damage",IF([Margin Damage]<>BLANK(), FORMAT([Margin Damage], "0.0%"), BLANK()),
"Margin Sales Parts",IF([Margin Sales Parts]<>BLANK(), FORMAT([Margin Sales Parts], "0.0%"), BLANK()),
"Margin Transport",IF([Margin Transport]<>BLANK(), FORMAT([Margin Transport], "0.0%"), BLANK()),
"Net Gross Margin",IF([Margin]<>BLANK(), FORMAT([Margin], "0.0%"), BLANK()),
"Gross Profit",[Gross Profit],SUM('P&L'[KUSD]))
 
Actual Color =
VAR actual = [Actual]
VAR actual_num =
    IF(ISBLANK(actual), BLANK(),
        VALUE(
            SUBSTITUTE(
                SUBSTITUTE(
                    SUBSTITUTE(actual, ",", "."),
                ".", ""),
            "%", "")
        )
    )
RETURN
IF(actual_num >= 0, "#118DFF", "#D64550")
and Now I have non-percentage and percentage numeric values
EchtRookie_0-1678742023646.png

 



 
 



View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks @ppm1 & @amitchandak  for your replies.

The soltion that I found was as following:

Actual = VAR var1 = IF(HASONEVALUE('Sort Account Type'[Account_Type]),VALUES('Sort Account Type'[Account_Type]),BLANK())
RETURN
SWITCH(var1,
"Margin Sales New",IF([Margin Sales New]<>BLANK(), FORMAT([Margin Sales New], "0.0%"), BLANK()),
"Margin Sales Used Direct",IF([Margin Sales Used Direct]<>BLANK(), FORMAT([Margin Sales Used Direct], "0.0%"), BLANK()),
"Margin Sales Used RV",IF([Margin Sales Used RV]<>BLANK(), FORMAT([Margin Sales Used RV], "0.0%"), BLANK()),
"Margin Rental incl Dep.",IF([Margin Rental incl Dep.]<>BLANK(), FORMAT([Margin Rental incl Dep.], "0.0%"), BLANK()),
"Margin Lease incl Dep.",IF([Margin Lease incl Dep.]<>BLANK(), FORMAT([Margin Lease incl Dep.], "0.0%"), BLANK()),
"Margin Damage",IF([Margin Damage]<>BLANK(), FORMAT([Margin Damage], "0.0%"), BLANK()),
"Margin Sales Parts",IF([Margin Sales Parts]<>BLANK(), FORMAT([Margin Sales Parts], "0.0%"), BLANK()),
"Margin Transport",IF([Margin Transport]<>BLANK(), FORMAT([Margin Transport], "0.0%"), BLANK()),
"Net Gross Margin",IF([Margin]<>BLANK(), FORMAT([Margin], "0.0%"), BLANK()),
"Gross Profit",[Gross Profit],SUM('P&L'[KUSD]))
 
Actual Color =
VAR actual = [Actual]
VAR actual_num =
    IF(ISBLANK(actual), BLANK(),
        VALUE(
            SUBSTITUTE(
                SUBSTITUTE(
                    SUBSTITUTE(actual, ",", "."),
                ".", ""),
            "%", "")
        )
    )
RETURN
IF(actual_num >= 0, "#118DFF", "#D64550")
and Now I have non-percentage and percentage numeric values
EchtRookie_0-1678742023646.png

 



 
 



ppm1
Solution Sage
Solution Sage

I would consider setting a conditional format string using a calculation group for this.

Controlling Format Strings in Calculation Groups - SQLBI

 

Pat

Microsoft Employee
amitchandak
Super User
Super User

@Anonymous , first of there is no need to multiply it by a hundred, keep ratio and use the option in the measure/column tool with the % symbol

 

Data Format New Rib.png

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

The thing is that in the column I have other values that aren't percentages. Thats why for those specific values I multply by a 100. Because if I use Format(value,"Pecentage") then it transform it to a string and my Actual color does not identify the values smaller than 0. and even if it's a negative it makes them blue insetad of red for those negative percentage values.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.