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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Using a lookup table to compare data with a specific comparator group.

I am fairly new to PowerBI, I have (I hope) a fairly simple problem. I have a fact table with some test results, connected to a "Name" table, that takes the following form, and it basically has students names, there region and a specific comparator group. 

NameRegionComp Group
SteveNN1
SarahSN2
WillWN3
PhilNN4
CarolineSN5


Now, I can filter the test data by Student, Year (when connected to a calendar table), and region all easily using slicers. But, I want to be able to filter by comparator groups N1-N5, where they are related to the students by the following table 

 

 

I am not sure how to do this, but my thinking was to introduce a slicer that lets me choose either region or comp group and if I chose either it then filters by those results based on the first selection, so fo example I can do this with region with the following measure: 

CG choice (region) = if(
SELECTEDVALUE(CG[CG])="Region",SUM('Fact'[Value]),"null"
 
and the graphs on the page then update based on my selections and all is fine. However, there needs to be some form of lookup with the comp group selection becuase each group N1-N5 is related to a list of names asd follows 
 
 
Comp GroupOriginal NameNN1NN2
N1SteveWillSarah
N2SarahWillPhil
N3WillPhilCaroline
N4PhilCarolineWill
N5CarolinePhilSarah
 
Please can someone advide me how to write a dax code that if I chose Comp Group in a filter, then looks up the name I chose to the orginal name column in this table and returns the original name, NN1 and NN2. And then, filters the graph by these names. So for example if I chose Will, in one slicer, then chose Comp group on the next slicer, then the graphs will update to show the test scores of Will, Phil and Caroline only.  
 
Thanks.
 
 
1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, I create a sample, this is the Test table.

vkalyjmsft_0-1658991621289.png

Comp Group table is the same with you, but don't make relationship with other tables.

vkalyjmsft_1-1658991802590.png

Here's my solution, create a measure.

Check =
IF (
    ISFILTERED ( 'Comp Group'[Comp Group] ),
    IF (
        MAX ( 'Test'[Name] ) = SELECTEDVALUE ( 'Comp Group'[Original Name] )
            || MAX ( 'Test'[Name] ) = SELECTEDVALUE ( 'Comp Group'[NN1] )
            || MAX ( 'Test'[Name] ) = SELECTEDVALUE ( 'Comp Group'[NN2] ),
        1,
        0
    ),
    1
)

Put the measure in the visual filter and select its value to 1.

vkalyjmsft_2-1658991932492.png

Get the correct result.

vkalyjmsft_3-1658992026425.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, I create a sample, this is the Test table.

vkalyjmsft_0-1658991621289.png

Comp Group table is the same with you, but don't make relationship with other tables.

vkalyjmsft_1-1658991802590.png

Here's my solution, create a measure.

Check =
IF (
    ISFILTERED ( 'Comp Group'[Comp Group] ),
    IF (
        MAX ( 'Test'[Name] ) = SELECTEDVALUE ( 'Comp Group'[Original Name] )
            || MAX ( 'Test'[Name] ) = SELECTEDVALUE ( 'Comp Group'[NN1] )
            || MAX ( 'Test'[Name] ) = SELECTEDVALUE ( 'Comp Group'[NN2] ),
        1,
        0
    ),
    1
)

Put the measure in the visual filter and select its value to 1.

vkalyjmsft_2-1658991932492.png

Get the correct result.

vkalyjmsft_3-1658992026425.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks that is aexactly what I am after and I have scaled it up to my big database. I just had two queries: (1) could you explain what the || symbols mean here, I tried to google it but couldn't fine the answer, and (2) could you explain why the max was used? - is it because you only want to find the comp group names for one authority only, and the one selected in the filter?  

Hi @Anonymous ,

Glad your problem is solved!

1. || is the OR operator, see the document: OR function (DAX) - DAX | Microsoft Docs

vkalyjmsft_0-1659430222116.png

2. The MAX function in a measure always return the current row of the column, because we can't directly reference a column in a measure, so we should add MAX/MIN/SUM before the column.

 

Best Regards,
Community Support Team _ kalyj

 

amitchandak
Super User
Super User

@Anonymous , Based On what I got, you want to compare two selected comp groups. If so, refer to my approch in the video

Compare two Brands: https://youtu.be/exN4nTewgbc

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors