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
Olia
Helper III
Helper III

Table Relationships: show only data in both tables

Hi everyone,

 

I have 2 tables: Headcount and Country names.

 

Country names is basically a connection to this page: https://www.worldatlas.com/aatlas/ctycodes.htm, so it has Country Name and 2 letter Code

Headcount... has the 2 letter country Codes, and as you can imagine, it has many rows with the same country code. 

 

I really want to make a slicer that will show Country Names for people to select.... but when I make a slicer with Country Name variable, it shows ALL country names that are listed on the webpage. I'd like it to show ONLY the country names for which I have a code in Headcount table.

 

 

edit: I don't think that the sample-dataset provided to me contains ALL the country codes that we have. so if anotehr user has more permissions, then it'd be nice if he could see the data for the countries that is unavailble to me as the maker of the report.

 

Any suggestions?

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Well, one way would be to create a table that did something like:

 

Slicer Table = 
VAR __tmpTable = DISTINCT('Headcount'[Code])
RETURN ADDCOLUMNS(__tmpTable,"Country",LOOKUPVALUE('Country'[Country Name],'Country'[Code],'Headcount'[Code]))

Something like that.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Well, one way would be to create a table that did something like:

 

Slicer Table = 
VAR __tmpTable = DISTINCT('Headcount'[Code])
RETURN ADDCOLUMNS(__tmpTable,"Country",LOOKUPVALUE('Country'[Country Name],'Country'[Code],'Headcount'[Code]))

Something like that.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I'm noobing something wrong: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

what does this mean?

Hmm, difficult to say. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

That being said, see attached PBIX.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I tried to make a measure instead of a table... (never made Tables before, so didn't even see that option there).

so of course that didn't work, lol.

 

Thank you very much for your help and your patience Greg!

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.