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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

add number of zeros dynamically based on the max value(no of digits) in column ssas dax

Hi Team,

 

I need to add number of zero dynamically into the calculations based on the max value (no of digits before decimal) point.

 

Dax Reference link: https://dax.do/3B3JEwkIK0m0P6/

 

Logic: For the below snapshot, 

  1. unit_price column having max value 4249567.30 we need to calculate number of digits before decimal point. i.e. 4249567=7( no of digits)
  2. Sales Amount column having max value 5371682.10 we need to calculate number of digits before decimal point. i.e. 5371682=7( no of digits)

 

 

RGV538_0-1647947169780.png

 

after getting no of digits then we need to use the same in below calculation (Dynamic zeros in red color below calculation)

Sample Query

"UnitPrice_Column",
FIXED ( [unit_Price], 2, 1 ) + 10000000 // 4249567 (i.e, Number Of Digits=7)
//Number of zeros = number of digits
,
"Sales_Column",
FIXED ( [Sales Amount], 2, 1 ) + 10000000 // 5371682 (i.e, Number Of Digits=7)
//Number of zeros = number of digits

 

 

 

I am using this query now

DEFINE
VAR Req_columns =
ADDCOLUMNS (
SUMMARIZECOLUMNS (
'Product'[Brand],
Customer[Occupation],
"unit_Price", CALCULATE ( SUM ( Sales[Unit Price] ) ),
"Salesamount", [Sales Amount]
),
"UnitPrice_Column",
FIXED ( [unit_Price], 2, 1 ) + 10000000 // 4249567 (i.e, Number Of Digits=7)
//We need to consider max value from [unit_Price] and addition with number of zeros 
,
"Sales_Column",
FIXED ( [Sales Amount], 2, 1 ) + 10000000 // 5371682 (i.e, Number Of Digits=7)
//We need to consider max value(5371682) from [Sales Amount] and addition with number of zeros
)

EVALUATE
Req_columns
ORDER BY [Sales Amount] DESC

 

Thanks In Advance

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You can meausre like

M1 = maxx(summarize(allselected(sales), 'Product'[Brand],
Customer[Occupation] , "_1",  CALCULATE ( SUM ( Sales[Unit Price] ) ) ) , [_1])

 

M2 = Power(10, len([M1]&"")

 

that will give you desired number

 

you can add code in summarize column too

 

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

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , You can meausre like

M1 = maxx(summarize(allselected(sales), 'Product'[Brand],
Customer[Occupation] , "_1",  CALCULATE ( SUM ( Sales[Unit Price] ) ) ) , [_1])

 

M2 = Power(10, len([M1]&"")

 

that will give you desired number

 

you can add code in summarize column too

 

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.