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
patri0t82
Post Patron
Post Patron

Creating a Measure to Switch between Names Columns, using USERELATIONSHIP

Hello, I have three columns in one table.

Table1[Name1]

Table1[Name2]

Table1[Name3]

 

I have another table called DistinctNames, which has a column called [Names], which as you can imagine, is a combination of all the names from the above three columns.

 

What I would like to do is create a slicer that contains a list of all the distinct names, and then filters my visuals, depending on which column(s) the name falls in. For example, if I click on John Smith, I need it to interact with Table1, regardless of which column his name falls in.

2 REPLIES 2
Greg_Deckler
Super User
Super User

@patri0t82 Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, 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

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ 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...

This is my desired result. Thank you very much for your help.

Sample Picture.png

 

 

 

Here is some sample code. This will give you Table1:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZTBbtswDIZfhfC5l9qO3R2dFmnQ1B2wACvQoAfCoWHBqpTKDjbt6SdLHgZJbtMjKZMf+ZP04ZBsFGmELYkjqUGK5Cq5IyHYAM80jMb6SUeEGtX7mf4YM8uT16tDsiY8w9NZWN8PemNwr1jbsrEzdo0ce2SwI6WmkJUNqQ1mR2LKuUNtULDv6HRCdTSeitNvhrDm2PTGXF27EOo7BredYsPIUMTV1DiOJGHDaWw6mmCOVQk0gXVzi2rUcUXVcCIBzx0bBU3PmcMZOhsItrJt3ywt1uaB2paUhloqJX/95wUJA3m0QNhzaXOusiKzMVGqTwW6+TYX6We7qFDpClxQ/HOJslVhA4N0sURMcNKwRcaNNbd2Qe4QXaSlU9FfgkigCJ7OtHAJfI1CfPlvRbRl9WR83xtCAZUSkh+X0GXq9v5FI1Nk/NqC/O7XqDkRVJwzty2O9CI5wh1O6C01o1SwFzapf2h5el1+MKvYE55cOR9ZMK7A3CgUPWcCHkkKlyhNlyZ2YYClKzTq15cjErHIHczv29fEH12aF/PS++0GmxLr4wpc6Df+dEmU/INBBHoucMulMQRyBq/FV24mRhXmf/D6Fw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name1 = _t, Name2 = _t, Name3 = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name1", type text}, {"Name2", type text}, {"Name3", type text}})
in
    #"Changed Type"

 

This code will retrieve the distinct names from Table1

let
    Source = List.Combine({List.Distinct(Table1[Name1]),List.Distinct(Table1[Name2]),List.Distinct(Table1[Name3])}),
    #"Removed Duplicates" = List.Distinct(Source),
    #"Converted to Table" = Table.FromList(#"Removed Duplicates", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Names"}})
in
    #"Renamed Columns"

 

This is a table you can use instead of Base64 above

 

Name1Name2Name3Value
Freya HendersonDennis WestVeda Marquez34
Beau NunezRemi GriffithMalakai Kerr35
Mya KentKayson SheppardAlexia Black51
Mekhi ChristianVeda MarquezMatteo Fletcher5
Anahi McCartyMalakai KerrAspen Whitney31
Blaise HoffmanFreya HendersonJeffery Morrow5
Aspen WhitneyBeau NunezReyna Sloan5363
Jeffery MorrowMya KentKayson Sheppard8931
Reyna SloanMekhi ChristianVeda Marquez75
Kayson SheppardAnahi McCartyMalakai Kerr356
Veda MarquezBlaise HoffmanFinley Hail63
Malakai KerrAspen WhitneyAnahi McCarty627
Alexia BlackJeffery MorrowBlaise Hoffman2
Matteo FletcherReyna SloanAspen Whitney7
Anaya BlakeOcean ArnoldJeffery Morrow724
Zyaire MoyerFinley HailBaylee Allison7
Zola DayHector SnowDennis West4217
Kayson SheppardKayson SheppardRemi Griffith735
Veda MarquezVeda MarquezFranklin Leonard22
Malakai KerrMalakai KerrAspen Whitney77
Baylee AllisonFinley HailJeffery Morrow642
Dennis WestHector SnowReyna Sloan246
Remi GriffithAlexia BlackKayson Sheppard7
Franklin LeonardKayson SheppardFranklin Leonard24
Kayson SheppardVeda MarquezKayson Sheppard77
Veda MarquezMalakai KerrVeda Marquez6
Malakai KerrAspen WhitneyKayson Sheppard61

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.