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
kuma
New Member

Regroup Values to make less objects showed in Column Legend?

Hello:

 

I have a dataset similar to below:

 

costdatename
1002022/6/13main-name-1
1012022/6/13main-name-2
1022022/6/13main-name-3
1032022/6/13subname-a-1
1042022/6/13subname-a-2
1052022/6/13subname-a-3
1062022/6/13subname-b-1
1072022/6/13subname-b-2
1082022/6/13subname-b-3

 

When I import the dataset in to a clustered column chart, 

It will be showed as below.

kuma_0-1655089518621.png

 I want to regroup the values 'subname' in field name to reduce objects displayed in chart,

For example, down to 3 objects:main-name/subname-a/subname-b, just like below:

kuma_1-1655090465216.png

Please help me achieve this.

Thank you very much.

 

1 ACCEPTED SOLUTION

8 REPLIES 8
tamerj1
Super User
Super User

Hi @kuma 
Here is a sample file with the solution https://www.dropbox.com/t/Ao5d3OS12zT88mDT

This is a general formula of a new column that removes the number (regardless of how many digits) from the end of the name

1.png2.png

 

New Name = 
VAR NameColumn = Data[name]
VAR Length1 = LEN ( NameColumn )
VAR NumericDigits = SELECTCOLUMNS ( GENERATESERIES ( 0, 9, 1 ), "@Digit", [Value] & "" )
VAR T1 = GENERATESERIES ( 1, Length1, 1 )
VAR T2 = ADDCOLUMNS ( T1, "@Letter1", IFERROR ( MID ( NameColumn, [Value], 1 ), BLANK ( ) ) )
VAR T3 = ADDCOLUMNS ( T2, "@Letter2", IF ( [@Letter1] IN NumericDigits, BLANK ( ), [@Letter1] ) )
VAR NewText = CONCATENATEX ( T3, [@Letter2] )
VAR Length2 = LEN ( NewText )
RETURN
    LEFT ( NewText, Length2 - 1 ) 

 

Hi @tamerj1

Thank you for the solution.

Actually in the name field there is a more complex pattern than I exampled.

There are four pattern below:

1.MC_[ResourceGroup name]-RESOURCES_[instanceID]_[Reigion]
 be like: MC_Corp-Platforms-RESOURCEGROUP-01-RESOURCES_AKSDEVTEST01_USEAST2
2.databricks-rg-[instanceID]-[SubResourceGroupID]
 be like: databricks-rg-ADBDevTest01-8vcbrmn9wnqks
3.[Main Resource Group name]
 be like :Corp-Platforms-RESOURCEGROUP-01
4.Others

What I want is:

a.regroup all objects in No.1 and display a name by [AKS] in legend.
b.regroup all objects in No.2 and display a name by [ADB] in legend.
c.keep all [Main Resource Group name] which has [Corp-Platforms]prefix in No.3,and display the values in legend.
d.do not display [others] in No.4.

Could you tell me how to achieve this? 

Thank you very much.

Hi @kuma 
Little confused. Would you please have the four examples in a table showing nput in one column and output in the other column

InputOutput
MC_Corp-Platforms-RESOURCEGROUP-01-RESOURCES_AKSDEVTEST01_USEAST2?
databricks-rg-ADBDevTest01-8vcbrmn9wnqks?
Corp-Platforms-RESOURCEGROUP-01?
"Others"?

Hi @tamerj1

Here are the examples what I want to get values output in the new column.

Please tell me how to archieve this,

Thank you very much.

InputOutput
MC_Corp-Platforms-RESOURCEGROUP-01-RESOURCES_AKSDEVTEST01_USEAST2AKS
databricks-rg-ADBDevTest01-8vcbrmn9wnqksADB
Corp-Platforms-RESOURCEGROUP-01Corp-Platforms-RESOURCEGROUP-01
"Others"

Others

@kuma 
I hope this is what you're looking for https://www.dropbox.com/t/hj5rU1wIXUuMrtCX

1.png2.png

Hi @tamerj1

 

Thank you very much.

This solution you provided can solve my issue.

Dhacd
Resolver III
Resolver III

Create a new calculated column by using the below formula

   Subname= left(name,len(name)-2)

add the new calculated column to the categories and it will be working. Reply if you have any doubts,

Mark as a solution if this works for you.

Thanks and regards,
Atma.

Hi Dhacd

 

Thank you for your reply.

I think this would help.

 

BTW, when I use 'create group' on this field, the value in new groups is settled automatically like below:

Is the any way I can manually edit the text displayed in legend? 

kuma_1-1655094250249.png

 

 

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.