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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
brunozanoelo
Helper V
Helper V

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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