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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
SebastianOliver
Frequent Visitor

Format value to currency and percent in the same row and get a numeric output.

Format value to currency and percent in the same row, and get a numeric output to sort them as numeric, not by alphabet.

 

My output is a table that I want to sort by the value. The problem is that the value right now is a text.

I leave the formula that I'm using:

 

 

Formatted Value = 
VAR Result = 
IF(
    SUM('Main Table'[VALUE]) <> 0,
    SWITCH(
        MAX('Main Table'[PL_ACCOUNT_TYPE_NAME]),
        "Revenue", CONVERT(FORMAT(SUM('Main Table'[VALUE]), "Currency"), CURRENCY),
        "Contribution Margin", FORMAT(SUM('Main Table'[VALUE]), "$#0,0"),
        "Gross Margin", FORMAT(SUM('Main Table'[VALUE]), "$#0,0"),
        "Overhead", FORMAT(SUM('Main Table'[VALUE]), "$#0,0"),
        "Non-Labor Operating Costs", FORMAT(SUM('Main Table'[VALUE]), "$#0,0"),
        "Total Labor Costs", FORMAT(SUM('Main Table'[VALUE]), "$#0,0"),
        "Gross Margin %", FORMAT(FORMAT(SUM('Main Table'[VALUE]), "Percent"), "General Number"),
        (AVERAGE('Main Table'[VALUE])* 100) & "%"
    )
)
Return
Result

 

 

SCR-20231129-tnle.png

1 REPLY 1
amitchandak
Super User
Super User

@SebastianOliver , I think you should is Dynamic format string for this

 

https://powerbi.microsoft.com/en-us/blog/deep-dive-into-the-new-dynamic-format-strings-for-measures/

 

Power BI Dynamic Format Strings for Measures| Format without converting to text: https://youtu.be/qHALucET7N8

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors