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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
akhilduvvuru
Helper III
Helper III

Show .4 as 0.4 when converted to millions using custom dynamic format

Team, I have amounts that should show in millions. If there is a negative value then should show in brackets. I'm using this custom dynamic logic to show the same.

 

 

"#,,.0;(#,,.0);#,,.0", "#,##0;(#,##0);#,##0"

 

 

This logic is working fine as expected for all the values except for the smaller amounts (mentioned in red below).
However,

1. For bigger amounts, the thousand comma seperator is not coming.

2. For smaller amounts, It should show as Expected Output field below.

AmountFormated in Millions (using above format) Expected Output
4,592,207,7224592.24,592.2
371,820,100371.8371.8
90,000,00090.090.0
-625(.0)(0) or (0.0)
575.0

0 or 0.0

0.0

0 or 0.0

304,665.3

0.3

 

Someone please help me with the expected output.

 

Thanks!!

1 ACCEPTED SOLUTION

Hi @akhilduvvuru ,
I'm sorry I'm not quite sure what you mean by duplic filed. But as I understand it, you can use measure to avoid reusing this field in the model.
1.Create a measure

Measure = SELECTEDVALUE('Table'[Amount])


2.Set measure format

vheqmsft_0-1706579266598.png

“#,#0,,.0;(##0,,.0);#,0.0”

3.Final output

vheqmsft_1-1706579567025.png

Regarding the switching between the two views before and after the conversion, in addition to using the filed parameter as described above, you can also use bookmarks for this purpose. Here are the steps:
1.Create two blank buttons and set name as millions and none

vheqmsft_3-1706579868417.png

 

vheqmsft_2-1706579837834.png
2.Create duplicate page

vheqmsft_4-1706579920737.png

3.Create two bookmarks and name them as miilions and none, in millions has all visiualizations and in none has only amount column

vheqmsft_5-1706580229671.pngvheqmsft_6-1706580237845.png

4.Apply these bookmarks to buttons

vheqmsft_7-1706580279610.png

5.At this point you can use the buttons to switch between the different views.
Because measure cannot exist independently of the original column data, it must exist with the AMOUNT column on top of the view.

Best regards

Albert He

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

7 REPLIES 7
v-heq-msft
Community Support
Community Support

Hi @akhilduvvuru ,

Here some steps that I want to share, you can check them if they suitable for your requirement.

Here is my test data:

vheqmsft_0-1706260637080.png

Create a measure

Measure = SELECTEDVALUE('Table'[Amount])/1000000

Then go to Measure Tools and set Format as dynamic and write this code

vheqmsft_1-1706260822410.png

"#0.0;(#0.0);#0.0"

Final output

vheqmsft_2-1706260875184.png

 

Best regards

Albert He

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thanks @v-heq-msft for your response. This works as expected for one of the requirements! Can you also help me with the comma thousand seperator? Eg: 4592207722 --> 4,592.2.

Also, I have a requirement where I have a slicer with 2 values (1. Millions, 2. None). When I select "Millions", I should show the amount in Millions as I explained in my requirement above. When I select "None", I should be able show the actual amount.

 

As you suggested, If I do Amount/1000000, I'm not able to switch between Millions and actual amount.

Thanks!!

Hi @akhilduvvuru ,
I have modified the above steps and code according to your needs,
1.Create a calculate column

Column = VALUE('Table'[Amount])

2.Change the format of the column in Model view
Select the column and create a number format code in Custom format

#,#0,,.0;(##0,,.0);#,0.0

 

vheqmsft_1-1706509222106.png
3.Create a filed parameter and rename Amount as Column as millions, Amount as None



vheqmsft_0-1706509051924.png

4. Drag parameter as columns of table

vheqmsft_2-1706509465385.png

5.Final output

vheqmsft_3-1706509493170.png

vheqmsft_4-1706509507893.png

Best regards

Albert He

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thanks for this @v-heq-msft - Is there a way where we can do it without duplicating the field? Because I have many fields like with the same formatting requirement. I cannot duplicate the field.

Thanks!! 

Hi @akhilduvvuru ,
I'm sorry I'm not quite sure what you mean by duplic filed. But as I understand it, you can use measure to avoid reusing this field in the model.
1.Create a measure

Measure = SELECTEDVALUE('Table'[Amount])


2.Set measure format

vheqmsft_0-1706579266598.png

“#,#0,,.0;(##0,,.0);#,0.0”

3.Final output

vheqmsft_1-1706579567025.png

Regarding the switching between the two views before and after the conversion, in addition to using the filed parameter as described above, you can also use bookmarks for this purpose. Here are the steps:
1.Create two blank buttons and set name as millions and none

vheqmsft_3-1706579868417.png

 

vheqmsft_2-1706579837834.png
2.Create duplicate page

vheqmsft_4-1706579920737.png

3.Create two bookmarks and name them as miilions and none, in millions has all visiualizations and in none has only amount column

vheqmsft_5-1706580229671.pngvheqmsft_6-1706580237845.png

4.Apply these bookmarks to buttons

vheqmsft_7-1706580279610.png

5.At this point you can use the buttons to switch between the different views.
Because measure cannot exist independently of the original column data, it must exist with the AMOUNT column on top of the view.

Best regards

Albert He

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amustafa
Super User
Super User

To format values in millions and ensure that a value like .3 million is displayed as 0.3, you can use a custom format string in Power BI. The format you are looking for would be something like "0.0,,;(-0.0,,);0.0,,". This format will show the values in millions with one decimal place and add a leading zero for numbers less than 1.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @amustafa 

Thanks for your quick response! Unfortunalty both your format strings are not working as expected. Both are returning the actual numbers.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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