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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Snagalapur
Helper IV
Helper IV

Add new column into data table with space using existing column

Hi All,

 

Please suggest how to add Column having space (customised based on need) based on data in existing column, so that when i use this New column into Martix table it should retain format Ex: below.

Snagalapur_1-1744215068930.png

 

 

Thank you.

1 ACCEPTED SOLUTION
Syk
Super User
Super User

You can create a calculated column. However, you'll need to ensure the Text Wrap for your values is off

Syk_0-1744215843325.png

 

View solution in original post

3 REPLIES 3
MarkLaf
Memorable Member
Memorable Member

Here is an approach in Power Query that uses non-breaking spaces (unicode 160). Non-breaking spaces won't get collapsed like regular spaces do in certain contexts (like when displayed in row headers). I added some inputs (LevelWeight, LevelLookup) that let you assign/update spacing a little more easily and transparently.

 

You can see how this works if you paste into Advanced Editor in Power Query. You can copy the relevant steps over to your own query, just be sure to update for column name differences. It's possible to do something very similar with DAX in a calculated column if needed.

 

let
    Source = Table.FromColumns( 
        {{"Type 1","Type 2","Type 3","Type 4","Type 5","Type 6"}}, 
        type table [Accounts = text]
    ),
    LevelWeight = 3, 
    LevelLookup = [ Type 1 = 0, Type 2 = 2, Type 3 = 1, Type 4 = 1, Type 5 = 0, Type 6 = 0 ],
    AddExpectedResult = 
    Table.AddColumn(
        Source, 
        "Expected result", 
        each Text.Repeat( 
            Character.FromNumber( 160 ) , 
            Record.Field( LevelLookup, [Accounts] ) * LevelWeight 
        ) & [Accounts], 
        type text
    )
in
    AddExpectedResult

 

Table in Power Query:

MarkLaf_0-1744217051937.png

 

Put into a matrix and you can see that spacing is not collapsed.

 

MarkLaf_1-1744217182472.png

 

Note that to have [Expected result] ignore the spacing when sorting, you will need to set the column's 'Sort by column' setting to [Accounts].

 

MarkLaf_2-1744217338286.png

Thank you so much for taking time on this. 

Syk
Super User
Super User

You can create a calculated column. However, you'll need to ensure the Text Wrap for your values is off

Syk_0-1744215843325.png

 

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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