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

Create text column based on slicer selection

Hello All

 

can anyone please help me in creating new text column based on slicer selection like below

Slicer
SonySamsungAppleNokiaRedmi

 

here i have selected Apple in the slicer, then my new column MaskName should be like below. other names should be masked.

this new column should be dymanic based on slicer selection. 

 

NameProductionMaskName
Sony100A
Samsung200B
Apple5420Apple
Nokia254C
Redmi365D

 

thanks in advance

Ganesh

3 REPLIES 3
lbendlin
Super User
Super User

Columns are static. You cannot create a column based on a slicer selection.  What you can do is create a measure.

 

Naming the other vendors A, B, C, D etc can be done by using a VALUES() list that needs to exclude the current selection.

 

NOTE: The slicer needs to be fed from an independent table that is not connected to the other tables in the data model.

Quick question - Does it have to be A, B, <vendor>, C, D etc  or can it also be A, B, <vendor>, D, E  etc?  That would be much easier to implement.

If that is acceptable then here is a possible solution.  It involves the use of RANKX to create a number sequence and then some character trickery to arrive at the desired outcome. This also limits you to 26 partners in the list 🙂

 

 

 

Measure = 
// partner list with sales
var r1 = SELECTEDVALUE('FactTable'[Partner])
// reference tabe just with unique partner names - this feeds the slicer
var r2 = SELECTEDVALUE('Reference'[Partner])
// RANKX returns 1,2,3 etc. We convert that to A, B, C etc
var g = rankx(allselected('FactTable'[Partner]),[v])+64
var r =  if(HASONEVALUE('FactTable'[Partner]),
       //show the selected partner name if it matches
       if(r1=r2,r1,
       // mask the other partners
       "Partner " & UNICHAR(g)),
       // suppress the total as it makes no sense
       BLANK())
return r

 

 

NOTE:  Having done similar exercises in the past I need to warn you. Partners are very smart. They figure out who "Partner C"  is in less time than it takes you to send the obfuscated data to them. You may want to apply some randomness to the process and - for example - add a calculated column to your fact table 

 

r = rand()

 

and then change the above measure v to say

 

v := average(r)

 

That will give you a different sort order of the partners every time you refresh the data source.

 

 

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.

Top Solution Authors