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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
lizlemon
New Member

Text slicer value that filters rows in table and produces text value

I have been all over trying to find the secret sauce to this.  I can create this in Excel, but I can't seem to figure it out in Power BI:

 

I have a list of names with 2 corresponding sites each.  I need a calculated column that will detect a selected Site value, give it a label, and apply it to the results.  

 

How I did it in Excel: 

 

I created a Table for Sites, which I used to define a name for a list of values for data validation.  I used this for the "Slicer" (dropdown cell) and for the 2 columns in the table defining SITEs.

 

My data table looks like this: 

 

SELECT SITE:BBBB

 

NAMESITE 1SITE 2Site Validation
StevenAAAABBBBHOME
VirginiaBBBBBBBBHOME
AllenBBBBDDDDHOME
CoreyCCCCAAAAAWAY
KariDDDDAAAAAWAY
MirandaDDDDCCCCAWAY
JasonEEEEQQQQAWAY

 

My formula for Site Validation (what I am trying to create in Power BI) is:  =IF(OR([@[SITE 1]]=SelectedSite,[@[SITE 2]]=SelectedSite),"HOME","AWAY")

 

I know you can't pass a slicer to a calculated column in Power BI, but I'm looking for an alternative.  It can't be impossible.  But if I try to use a parameter in Desktop, it does not give me a text option unless I am in the Query Editor.  Anyone have any ideas?

 

I have tried anyway using SELECTEDVALUE and it of course doesn't work, but it does if I put in a static text value instead.

1 ACCEPTED SOLUTION
Irwan
Super User
Super User

hello @lizlemon 

 

please check if this accomodate your need.

Irwan_1-1744773518724.png

for your case, i would like something like below

1. create a dim table for Site consisted of all Site. In this example, i summarize all combined value from SITE1 and SITE2.

Irwan_3-1744773651831.png

if you have a dim table already or a list of Sites, then you can skip this step.

 

2. create a new measure with following DAX

Home Validation =
var _Site = SELECTEDVALUE('Site'[Table_SITE 1])
Return
IF(
    SELECTEDVALUE('Table'[SITE 1])=_Site||SELECTEDVALUE('Table'[SITE 2])=_Site,
    "Home",
    "Away"
)
 
3. plot in SITE dim table in slicer and the measure above in table visual
Irwan_4-1744773798036.png
Irwan_5-1744773807827.png

 

Hope this will help.

Thank you.

View solution in original post

5 REPLIES 5
Irwan
Super User
Super User

hello @lizlemon 

 

please check if this accomodate your need.

Irwan_1-1744773518724.png

for your case, i would like something like below

1. create a dim table for Site consisted of all Site. In this example, i summarize all combined value from SITE1 and SITE2.

Irwan_3-1744773651831.png

if you have a dim table already or a list of Sites, then you can skip this step.

 

2. create a new measure with following DAX

Home Validation =
var _Site = SELECTEDVALUE('Site'[Table_SITE 1])
Return
IF(
    SELECTEDVALUE('Table'[SITE 1])=_Site||SELECTEDVALUE('Table'[SITE 2])=_Site,
    "Home",
    "Away"
)
 
3. plot in SITE dim table in slicer and the measure above in table visual
Irwan_4-1744773798036.png
Irwan_5-1744773807827.png

 

Hope this will help.

Thank you.

So, YES, this works as intended!  However it did present another challenge I am trying to work around.  I now have the HOME and AWAY values, but the table does not filter anymore with related table slicers.  

 

If you have any ideas for that, I am all ears, but I have to say that for my original problem, this worked like a charm!

hello @lizlemon 

 

glad to be a help.

also do you mind describing more about the "table does not filter anymore with related table slicers.".

share some data would be great.

Thank you.

The issue is that if I want to filter the table view(s), the data does not filter with slicers or selecting anything that would normally filter a table visualization.

 

I have another table in Power BI that has all instances of when a person visits each site, but each person has 2 "Home" sites.  

 

The request is to filter the People that visit each site, and to label if they are a "Home" site person or an "Away" site person.  So I can filter by Site AAAA, and I will see everyone that has visited site AAAA, whether or not AAAA is their home site, but if they never visited AAAA, they would not appear in the table.

 

I did not provide this side data because I did not think about that part not working, but here is some sample data and expected results: 

 

Visit Data: 

 

NameSite
StevenBBBB
VirginiaCCCC
AllenEEEE
CoreyAAAA
KariBBBB
MirandaCCCC
JasonEEEE
StevenDDDD
VirginiaQQQQ
AllenBBBB
CoreyBBBB
KariCCCC
MirandaDDDD
JasonQQQQ
StevenAAAA
VirginiaAAAA
AllenQQQQ
CoreyEEEE
KariDDDD
MirandaQQQQ
JasonFFFF
StevenEEEE
VirginiaSSSS
AllenCCCC
CoreyCCCC
KariTTTT
MirandaBBBB
JasonAAAA

 

Intended Results:  The table in Power BI would filter to this: 

 

SELECT SITE:BBBB

 

NAMESITE 1SITE 2Site Validation
StevenAAAABBBBHOME
AllenBBBBDDDDHOME
CoreyCCCCAAAAAWAY
KariDDDDAAAAAWAY
MirandaDDDDCCCCAWAY

 

If there is a modification for the measure to make this happen, I am all ears!  I'm sure that's got to be what it is if it's going to work.  🙂

 

 

hello @lizlemon 

 

i might be misunderstood but i assumed your data has one column of Site instead of two columns as you have shown previously.

however, i am not sure how to decide which one become Site 1 and Site 2 since each Name has four site based on your sample data above. So i use all those four site, you can change based on your preferences.

Irwan_1-1745021342723.png

 

But anyway, please check if this accomodate your need.

I tried to do your sample data in PQ and DAX, so you can choose any of them.

The Home Validation measure between PQ and DAX below looks different because of index ordering between PQ and DAX (again i dont know how to differentiate the Site).

Irwan_0-1745021311160.png

 

the idea is to differentiate which Site 1 and Site 2, then plot them into Matrix visual since you have one column of Site.

 

Detail is in pbix attached.

 

Hope this will help.

Thank you.

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors