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

issue with filter context formula

Hi all,

 

I am getting in the topic of filter context and I would like to create an easy formula in my report that filters based on values in another table.Somehow however it doesn't work and therefore I created an example sample with 2 Tables. 

 

I would need to sum up the 'hours' in table 1 based on the department filter. Hence, result would need to be 4

 

YBZ_2-1644586398311.png

 

Could you please support? That would be much appreciated!

 

Regards

 

 

 

 

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @YBZ ;

Is your problem solved?? If so, Would you mind accept the helpful replies as solutions? Then we could close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yalanwu-msft
Community Support
Community Support

Hi, @YBZ ;

Try it,

SumHours =
CALCULATE (
    SUM ( Table1[hours] ),
    FILTER (
        Table1,
        Table1[department] IN ALLSELECTED ( TableSelectedDepartment[department] )
    )
)

Or

SumHours =
CALCULATE (
    SUM ( Table1[hours] ),
    FILTER (
        Table1,
        Table1[department] = MAX ( TableSelectedDepartment[department] )))

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

David-Ganor
Resolver II
Resolver II

Hi @YBZ 

 

First of all, you can create a realtionship between the tables - with direction from TableSelectedDepartment to 1,  So basically TableSelectedDepartment  acts like a dimension.

If that somhow not possible you can create the following measure:

SumHours=

Calaculate(Sum(Table1[hours])

,FILTER(Table1

,Table1[department]=TableSelectedDepartment[department]))

 

Hope it helps,

 

David Ganor

Thanks, I would indeed a measure as I made the connection in my database too difficult... 🙂 

 

I understand the logic behind it, but when I try it in PowerBI, it seems that PowerBI only allows me to put a measure for TableSelectedDepartment[department]).

 

SumHours=

Calaculate(Sum(Table1[hours])

,FILTER(Table1

,Table1[department]=TableSelectedDepartment[department]))

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
Top Kudoed Authors