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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
TITO22
Frequent Visitor

Format of column dynamic

Hello everyone,

 

I want to make the format of my column Sales/QTY dynamic according to the ProductID:
when ProductId = 2 ==> 2 decimal
ProductId = 3 ==> 3 decimal
Please check the table below

 

Product IdSales/QTY
1003
10,2
20,03
30,005
40,0006

 

Thank you

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @TITO22 

 

Sample:

vxuxinyimsft_1-1709186774615.png

 

You can create a measure as follows.

 

Sales/QTY1 = 
VAR _rept = MAX([Product id])
VAR _sales = MAX([Sales/QTY])
VAR _number = IF(LEN(_rept) = 1, CONCATENATE(REPT(0, _rept), _sales), _sales)
RETURN
IF(LEN(_rept) = 1, LEFT(_number, 1) & "." & RIGHT(_number, _rept), _sales)

 

 

Modify the Format:

vxuxinyimsft_3-1709187083058.png

 

Best Regards,
Yulia Xu

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @TITO22 

 

Sample:

vxuxinyimsft_1-1709186774615.png

 

You can create a measure as follows.

 

Sales/QTY1 = 
VAR _rept = MAX([Product id])
VAR _sales = MAX([Sales/QTY])
VAR _number = IF(LEN(_rept) = 1, CONCATENATE(REPT(0, _rept), _sales), _sales)
RETURN
IF(LEN(_rept) = 1, LEFT(_number, 1) & "." & RIGHT(_number, _rept), _sales)

 

 

Modify the Format:

vxuxinyimsft_3-1709187083058.png

 

Best Regards,
Yulia Xu

 

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

Thank you 👍

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors