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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Singaravelu_R
Resolver III
Resolver III

How to show Max of Length of text in Table based on slicer selection

Hi Team,

Greetings!

 

My requirement is I have employee Name, Employee location, Employee Designation in my slicer. if I select any slicer or all slicer (one value or multiple value) I want to show Max length of selected value Text number in my bar chart.

 

Example: Assume , are selected value of slicer. So based on my current selection my Bar chart would show the value of 6 as of Max length of selected slicer value is Carref = length of character is 6. Please give your suggestion how can we achieve this. Thanks for you help.

 

Employee NameEmployee locationDesignation
x ,kar ,xxx
y ,bard ,yyy
z ,carref ,zzz
 ff 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Singaravelu_R ,

You can create a measure as below, please find the attachment for the details.

Measure = 
VAR _tab =
    SUMMARIZE (
        'Employee' ,
        'Employee'[Employee Name],
        'Employee'[Employee location],
        'Employee'[Designation],
        "_lenofename", LEN ( 'Employee'[Employee Name]  ),
        "_lenofelocation", LEN (  'Employee'[Employee location] ),
        "_lenofdesignation", LEN ( 'Employee'[Designation]  )
    )
VAR _lempname =
    MAXX ( _tab, [_lenofelocation] )
VAR _lemplocation =
    MAXX ( _tab, [_lenofelocation] )
VAR _ldesignation =
    MAXX ( _tab, [_lenofdesignation] )
RETURN
    MAX ( MAX ( _lempname, _lemplocation ), _ldesignation )

yingyinr_0-1616465052397.png

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Singaravelu_R ,

You can create a measure as below, please find the attachment for the details.

Measure = 
VAR _tab =
    SUMMARIZE (
        'Employee' ,
        'Employee'[Employee Name],
        'Employee'[Employee location],
        'Employee'[Designation],
        "_lenofename", LEN ( 'Employee'[Employee Name]  ),
        "_lenofelocation", LEN (  'Employee'[Employee location] ),
        "_lenofdesignation", LEN ( 'Employee'[Designation]  )
    )
VAR _lempname =
    MAXX ( _tab, [_lenofelocation] )
VAR _lemplocation =
    MAXX ( _tab, [_lenofelocation] )
VAR _ldesignation =
    MAXX ( _tab, [_lenofdesignation] )
RETURN
    MAX ( MAX ( _lempname, _lemplocation ), _ldesignation )

yingyinr_0-1616465052397.png

Best Regards

TomMartens
Super User
Super User

Hey @Singaravelu_R ,

 

create a measure for each sllicer in your report

 

slicer 1 = 
MAXX(
    VALUES( 'tablename'[columnname] )
    , var __columnValue = 'tablename'[columnname]
    var __columnValueLength = LEN( __columnValue )
    return
    __columnValueLength
)

 

You may want to differentiate if at least one item inside the slicer is selected, and for this you can consider to incorporate the function ISFILTERED(...) like so.

 

slicer 1 =
IF( ISFILTERED( 'tablename'[columnname] )
    , ...
    , BLANK()
)

 

Finally create a measure that returns the MAX value from all the measures like so:

 

max length =
MAX( [sllicer 1] , [slicer 2] , ... , [slicer n] )

 

 

Use the measure [max length] for your data visualization.

 

Of course it's also possible to create just one measre using variables, that store the value for each slicer, the final operation is then is to get the MAX from the variables, this is of course depends on your likings.

 

Personally I try to reduce the number of measures, but also try to keep each measure as short as possible.

 

Hopefully, this helps to tackle your challenge.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
amitchandak
Super User
Super User

@Singaravelu_R , len can give length , A measure like

 

len(selectedvalues(Table[Employee Location])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors