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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Dynamic Decimal Places

Hi,

 

I am currently dealing with an issue whereby I want the number of decimal places for a measure be dynamic.

 

The use case is, if I select Option A in a slicer, the measure shows 2 decimal places. If I then select Option B for the slicer, the measure will show 1 decimal place.

 

However, I also need to keep the measure as a number, not text.

 

My current Dax is:

 

Measure 2 = 
IF(HASONEVALUE(Table[Slicer]) && VALUES(Table[Slicer]) = "A", 
FORMAT(ROUND([Measure1], 2), ""), 
FORMAT(ROUND([Measure1], 1), ""))

 

 

 

This returns the correct values but as text not a number. Is anyone able to help? Cheers

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

It seems impossible to make the number fields show with one decimal place and two decimal places at the same time if you still want to keep its data type as Numeric type...

Best Regards

Rena

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

What are using format round should be enough

Measure 2 =
IF(HASONEVALUE(Table[Slicer]) && VALUES(Table[Slicer]) = "A",
ROUND([Measure1], 2),
ROUND([Measure1], 1))

 

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
Anonymous
Not applicable

Thanks for the suggestion. I have tried this, but when I toggle to Option B, I am left with trailing 0's.

 

E.g. If Table[Slicer] = "B"


My values will be:

9.80

8.40

3.30

 

And so on. I need them to be 9.8, 8.4.... 

This is when the number of decimal places for the filed formatting and the matrix formatting are both auto.

Anonymous
Not applicable

Hi @Anonymous ,

It seems impossible to make the number fields show with one decimal place and two decimal places at the same time if you still want to keep its data type as Numeric type...

Best Regards

Rena

Anonymous
Not applicable

Hi @Anonymous,

 

Thanks for the straight answer. I am currently using a workaround solution with one matrix column containing text with dynamic decimals, then another column with numeric values for the data bars (without data labels). Obviously not an ideal solution.

 

Would you recommend submitting this as a feature request?

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.