Reply
Anish7117
New Member

Trying to filter excel table in Power BI directly to make calculations

I have a PowerBI Project with an excel sheet containing 4 columns.

 

1. Country

2. Subject

3. Student Name

4. Student Score

 

I have another table with the following:

 

1. Country

2. Subject

3. Student Name

4. The Peers

The peers are all the students which are the peers to the current selected student. So the score is calculated from the first excel table.

 

What I want to do is,

 

in PowerBI, if I select the Student Country and Name, PowerBI automatically filters it in the second table and Find the Peer Names.

So I can calculate the Peer Scores from the first table. As of now, I have to manually enter the Peer Names in table 2 (From where the list is being fetched). How can I do it? is there a possibility of a virtual table or something?

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi,

Thanks for the solution lbendlin offered, and i want to offer some more information for user to refer to.

hello @Anish7117 ,you can refer to the following sample.

Sample data 

Table

vxinruzhumsft_0-1725244107080.png

 

Table(2)

vxinruzhumsft_1-1725244124997.png

You can create the following meaures

MEASURE =
VAR a =
    CALCULATETABLE (
        VALUES ( 'Table (2)'[The Peers] ),
        ALL ( 'Table (2)' ),
        'Table (2)'[Country] IN VALUES ( 'Table'[Country] ),
        'Table (2)'[Student Name] IN VALUES ( 'Table'[Student Name] )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Student Score] ),
        ALL ( 'Table' ),
        'Table'[Student Name] IN a
    )
Measure 2 = SUMX(VALUES('Table'[Student Name]),[Measure])

Then put the measure2 to the visual.

vxinruzhumsft_2-1725244459953.png

 

Best Regards!

Yolo Zhu

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

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi,

Thanks for the solution lbendlin offered, and i want to offer some more information for user to refer to.

hello @Anish7117 ,you can refer to the following sample.

Sample data 

Table

vxinruzhumsft_0-1725244107080.png

 

Table(2)

vxinruzhumsft_1-1725244124997.png

You can create the following meaures

MEASURE =
VAR a =
    CALCULATETABLE (
        VALUES ( 'Table (2)'[The Peers] ),
        ALL ( 'Table (2)' ),
        'Table (2)'[Country] IN VALUES ( 'Table'[Country] ),
        'Table (2)'[Student Name] IN VALUES ( 'Table'[Student Name] )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Student Score] ),
        ALL ( 'Table' ),
        'Table'[Student Name] IN a
    )
Measure 2 = SUMX(VALUES('Table'[Student Name]),[Measure])

Then put the measure2 to the visual.

vxinruzhumsft_2-1725244459953.png

 

Best Regards!

Yolo Zhu

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

 

lbendlin
Super User
Super User

That is a standard "Filtering Up"  pattern.  Read about REMOVEFILTERS.  You only need one table.

avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)