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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pbeeyeqs
Helper I
Helper I

SUMMARIZE function: Table with padded column?

I am trying to create a table from another table and would like to pad one of the columns with leading zeros.

 

I am using:

 

SUMMARIZE(products,products[Appl_No])

and would like the column [Appl_No] to be 6 digits, padding with zeros, if necessary.

1 ACCEPTED SOLUTION

hi, @pbeeyeqs 

You could try this formula logic to create the new table

Table = SELECTCOLUMNS(SUMMARIZE(Table1,Table1[Column1]),"Column1", RIGHT("000000"&[Column1],6))

Best Regards,

Lin

 

Community Support Team _ Lin
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

3 REPLIES 3
Anonymous
Not applicable

You can add a conditional column with dax like this:

AppLeading0 =
If( Len( products[Appl_No]) = 1 ; 00000 &  products[Appl_No];
If( Len( products[Appl_No]) = 2 ; 0000 &  products[Appl_No];

If( Len( products[Appl_No]) = 3 ; 000 &  products[Appl_No];
If( Len( products[Appl_No]) = 4 ; 00 &  products[Appl_No];
If( Len( products[Appl_No]) = 5 ; 0 &  products[Appl_No];
If( Len( products[Appl_No]) = 6 ;  products[Appl_No]; "Invalid length" ))))))

I know it will not be the most beautyfull solution, but it will do the job. 🙂 


So, having issues: 

To create the table with 2 columns using summarize, can't figure out how to get the 2nd column. So far I have:

 

=SUMMARIZE(table1,table1[column])

Which is fine for the first column. How can I add to this to make the 2nd column to be the same as the first column with padding to make 6 characters in length?

 

COLUMN 1     COLUMN 2

14325               014325

22                     000022

415263             415263

ABC                  000ABC

 

 

 

 

hi, @pbeeyeqs 

You could try this formula logic to create the new table

Table = SELECTCOLUMNS(SUMMARIZE(Table1,Table1[Column1]),"Column1", RIGHT("000000"&[Column1],6))

Best Regards,

Lin

 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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