Forum Discussion

VincenzoDelaVeg's avatar
VincenzoDelaVeg
New Member
2 years ago
Solved

Creating a Filter to Display All Client Values Based on a Specific Value in PowerBI

This is my first post in the PowerBI community, so apologies if the format isn't perfect. As far as I know, this question hasn't been posted yet.

 

I have a table with client IDs, and each client has specific values. I would like to create a filter that, when I select "Value = B", shows me a table containing the client ID and the values for all clients who have any mention of value B.

 

For example, it would show all values for Clients 1, 2, and 3, but not for Client 4, since Client 4 doesn't have a value of B. I would ideally have a slicer where I can choose 4, so this will allow me to change the value that I need (I have around 500 choices in my table).

 

If I were to write this in SQL, it would look something like the query below. Despite my best efforts, I just can't figure out how to achieve this in PowerBI.

 

 

 

 

select ClientId, Value
from table
where clientid in (select * from table where Value = B)

 

 

 

 

This is the table that I have:

ClientidValue
1B
1C
1D
1F
1G
1I
1J
2B
2E
2F
2H
2I
2J
3A
3B
3D
3F
3H
3J
4A
4C
4E
4G
4I
4J

 

And this is what I am after (ClientId 4 is therefore gone because it does not have the value B)

ClientidValue
1B
1C
1D
1F
1G
1I
1J
2B
2E
2F
2H
2I
2J
3A
3B
3D
3F
3H
3J

 

 

My method so far
I create a copy of the table in DAX and making sure I have distinct values.

 

 

 

 

 

 NewTable = DISTINCT(SELECTCOLUMNS('Table', "Value", 'Table'[Value], "Clientid", 'Table'[ClientId]))

 

 

 

 

 

Then I create a measure that reads from NewTable when select B, and attemps to export the list of ClientID

 

 

 

 

 

Filtered_ClientID = 
CALCULATETABLE (
    DISTINCT('Table'[ClientId]),
    FILTER (
        'Table',
        'Table'[Value] IN VALUES ( 'NewTable'[Value] )
    )
)

 

 

 

 

 

The problem is that (1) I feel like I'm going in circle with my problem and (2) This Filtered_ClientID is throwing an error that there are multple value per column, which is exactly what I am trying to extract. 

 

Thanks a lot! By the way, how come I cannot insert a PowerBI file into the chat... isnt it the PowerBI forum? /s