The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
Thank you.
Solved! Go to Solution.
You can create a calculated column. However, you'll need to ensure the Text Wrap for your values is off
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:
Put into a matrix and you can see that spacing is not collapsed.
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].
Thank you so much for taking time on this.
You can create a calculated column. However, you'll need to ensure the Text Wrap for your values is off