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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
brunozanoelo
Post Patron
Post Patron

How can i Format the value?

Following this article:
https://community.powerbi.com/t5/Desktop/How-to-change-measure-value-using-parameters/td-p/46011

Variable Calculation =
VAR Costs =
    SUM ( Sales[Cost] ) //Change with your measure 

VAR Quantitys =
    SUM ( Sales[Quantity] ) //Change with your measure 

VAR Weights =
    SUM ( Sales[Weight] ) //Change with your measure 

VAR SelectMeasure =
    MIN ( CalculationTable[SortID] )

RETURN
    IF (
        HASONEVALUE ( CalculationTable[Calculation Name] );
        
               SWITCH ( SelectMeasure; 
                                            1; Costs;
                                            2; Quantitys; 
                                            3; Weights 
                               )
    )



And how can i format those values in the DAX return?


Example:
50

IF the choice is Price, the value must be seen with brazilian coin format (R$ 50,00).
IF the choice is Quantity, the value must be seen like 50,00
IF the choice is weight, the value must be seen like 50,0000

How can i do that?

Thank's for all!

1 ACCEPTED SOLUTION
CahabaData
Memorable Member
Memorable Member

There would be no way to comingle differing field types within a DAX result field (...that I can think of...).

 

Instead one would have math only in your primary field, then include a 2nd field/column with a Type indicator value/flag.

 

Then one could calculate a 3rd column/field that creates a text value (because R$ symbols) based upon these 2 field values.

 

....and this is just thinking out loud - - could be more issues when it comes to implementation logic.....

 

 

www.CahabaData.com

View solution in original post

3 REPLIES 3
karthik
Advocate I
Advocate I

You can use the FORMAT function in your switch statement. However, FORMAT returns blank text when the value is blank so you will end-up facing issues with blanks being reported (blank won't be suppressed as it's a blank string not a BLANK()) in many places. You need to include visual level filters to exclude blank in all the places.

 

It's frustrating not to set the format string dynamically (e.g. scope statements in SSAS multi-dimensional) hopefully this gets addressed in the future releases.

Soo, i think this will not be possible to make =/

 

Serious, in tableau this is SO MUCH EASY TO MAKE, the tool already understand what format should use, every field have a ID, why power bi don't understand the format when the field is setting in the sum()?

''hopefully this gets addressed in the future releases.'' ME 2.

CahabaData
Memorable Member
Memorable Member

There would be no way to comingle differing field types within a DAX result field (...that I can think of...).

 

Instead one would have math only in your primary field, then include a 2nd field/column with a Type indicator value/flag.

 

Then one could calculate a 3rd column/field that creates a text value (because R$ symbols) based upon these 2 field values.

 

....and this is just thinking out loud - - could be more issues when it comes to implementation logic.....

 

 

www.CahabaData.com

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.