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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mallik999
Helper I
Helper I

Dynamic Decimal places each country wise

Hi All,

 

I have a country table contains 3 country like India,US,UK

country | Decimal Place

IN   2

US  3

UK  4

 

while showing the values based on country wise i want display my sales amount with those decimals places only

how do i pass Decimal places values dynamically to my format Function

after sometime my country's table will grow

Could you please help me on this.

For now i used the below DAX:

IF(Query1[COUNTRY]="IN",FORMAT(Query1[PRODUCT_VAL],"0.00"),IF(Query1[COUNTRY]="US",FORMAT(Query1[PRODUCT_VAL],"0.000")))
 

Regards

Mallikarjun 

 

4 REPLIES 4
Fowmy
Super User
Super User

@mallik999 

The downside to this approach is the result is a text, allows no calculation. If you want to have it, 1st create a table of countries and their respective decimal places like below

Fowmy_0-1599732684943.png
Add a measure as follows:

 

 

 

New Value = 

VAR COU = SELECTEDVALUE(Query1[Country])
VAR DEC = LOOKUPVALUE(CountryDemimal[Decimal],CountryDemimal[Country],COU,"0,0.00")

RETURN

IF( NOT ISBLANK(COU) , 
    FORMAT(MAX(Query1[PRODUCT_VAL] ), DEC)
)

 

 

 


You will have the desired output and it is dynamic when more countries are added:

 
 

Annotation 2020-09-10 131356.png



________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn



 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Be aware that if you return a STRING from a measure, you will not then be able to use this number-like string in calculations elsewhere unless you start casting the string to a number everywhere. This may greatly reduce the speed of your calculations and will be awkward. It's much better to create 2 measures: one will return a raw number and the other one will be the one that'll do the formatting and will be used a top-level measure for presentation.
amitchandak
Super User
Super User

@mallik999 , See if a measure like this can help

 

//line level

Switch( True() ,
max(Query1[COUNTRY])="IN",FORMAT(Query1[PRODUCT_VAL],"0.00"),
Max(Query1[COUNTRY])="US",FORMAT(Query1[PRODUCT_VAL],"0.000") )

 

// based on selected value from slicer

Switch( True() ,
selectedValue(Query1[COUNTRY])="IN",FORMAT(Query1[PRODUCT_VAL],"0.00"),
selectedValue(Query1[COUNTRY])="US",FORMAT(Query1[PRODUCT_VAL],"0.000") )

Anonymous
Not applicable

I am facing same issue but this solution is not helping. 

 

I am having a measure called Amount. 

i want this measure to display value based on another column code.

 

if code is 0 no decimal value, if code is 1 one decimal value , if 2 then 2 values if 3 then 3.

 

i did this but seems not to be working : 

 

oustanding_Amount:=Switch( True() ,
selectedValue(Test_code[code])=0,FORMAT([Amount],"0"),
selectedValue(Test_code[code])=1,FORMAT([Amount],"0.0"),
selectedValue(Test_code[code])=2,FORMAT([Amount],"0.00"),
selectedValue(Test_code[code])=3,FORMAT([Amount],"0.000"))

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors