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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
HassanAshas
Helper V
Helper V

Creating a slicer/filter based upon a measure that calculates aggregate values

Hi, I have a dataset like this, 

 

DateEmp CodeNameAllocationProject Code
1/1/20231Matt0.4Bench
1/1/20231Matt0.2A
1/1/20231Matt0.3C
1/1/20232Avery0.6A
1/1/20233Aryub1C
1/1/20234Jacob0.1Bench
1/1/20234Jacob0.1C
1/1/20234Jacob0.4A
1/1/20235Zara0.6Bench
1/1/20235Zara0.4C
2/1/20231Matt0.4Bench
2/1/20231Matt0.2A
2/1/20232Avery0.6Bench
2/1/20232Avery0.3A
2/1/20233Aryub1C
2/1/20234Jacob0.5Bench
2/1/20234Jacob0.4A
2/1/20235Zara0.8Bench
2/1/20235Zara0.1C

 

I have two values that are being calculated through DAX Measures (special thanks to tamerj1 for the help in creating these)

 

  1. Non-Allocated Resources: Total Number of Employees who are more than 50% on Bench 
  2. Allocated Resources: Total Number of Employees who are more than 50% on Projects other than Bench '

These are being calculated based upon the following logic, (considering Emp No. 1 Matt in December Month)

 

 

For Emp Code: 1, Matt 

Allocation on Projects: 0.2 + 0.3 = 0.5 
Allocation on Bench: 0.4 
Total Allocation = 0.4 + 0.5 = 0.9 

So, to calculcate individual ratio on projects/bench,

Total Allocation on Projects = Total Allocation on Projects / Total Allocation 
Total Allocation on Projects: 0.5 / 0.9 = 0.55

Total Allocation on Bench = Total Allocation on Bench / Total Allocation 
Total Allocation on Bench: 0.4 / 0.9 = 0.44

Since Allocation on Projects > Allocation on Bench, so Emp Code is Allocated

 

 

The DAX that is being used to solve this (it's same as provided by tamerj1) 

 

 

Total Allocated Employees = 
SUMX (
    VALUES ( Competency[Name] ),
    VAR CurrentEmpTable = CALCULATETABLE ( Competency )
    VAR OtherProjects = FILTER ( CurrentEmpTable, Competency[Project Code] <> "Bench" )
    VAR TotalAllocation = SUMX ( CurrentEmpTable, Competency[Allocation] )
    VAR OtherProjectsAllocation = SUMX ( OtherProjects, Competency[Allocation] )
    VAR PercentAllocation = DIVIDE ( OtherProjectsAllocation, TotalAllocation )
    RETURN
        INT ( PercentAllocation > 0.5 )
)

 

 

(and same for Non-Allocated Resources, with a little bit of tweek in the logic)

 

What I need to do is actually Filter my Table based upon these two measures. That is, I need to provide user with a slicer to select between Allocated and Non-Allocated Resources

If he selects Allocated then it should filter the data to only contain those employees who are allocated.

 

Issue that I am facing is, it is not possible to make a calculated column because for every employee, I need to access multiple rows in the current filter context (e.g. Month selected) and then check if he is allocated or not). And if the filter context changes (e.g. we select all the Months) then the value for calculated column will also change. 

 

I tried to create a SUMMARIZE Table where I summarized the fact table based upon Emp ID and Date, and stored SUM of the Allocated values for each employee and then tried to filter using that table, but again, that didn't work because it is possible that the filter context might change. 

 

Result I am trying to achieve:

 

Right now, it is showing me complete data, like this

 

HassanAshas_0-1677078618142.png

 

What I need to do is if I select Allocated Resources (with Month filter selected to January), it should show me only the following 4 resources (that have allocation = 1) and also change total value accordingly. So, from the following picture, Zara should be excluded. 

 

HassanAshas_2-1677078705743.png

And similarly, in Feb, for Allocated Resources, only Aryub should be visible. 

HassanAshas_3-1677078728897.png

Can anyone help out in resolving such a problem? I did try to look into various solutions such as using Field Parameter, but couldn't find any that helped me out, or maybe I couldn't understand those solutions properly. If you are aware of any good solution, please refer me to that, would be grateful for that. 

 

If you would like to download the Power BI file, you may do so from here: https://drive.google.com/file/d/1wh33gJkQelff3pC60K1AHELcsonTAQa4/view?usp=sharing

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @HassanAshas,

You can create a new calculated table with "Non-Allocated Resources" and "Allocated Resources" types and use this new field as source of slicer.

Then you can write a measure formula to extract the selection to compare with current calculation results and return flag.  

After these steps, you can use the formula on the ‘visual level filter’ to interact and filter records based on slicer selections.

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

HI @HassanAshas,

You can create a new calculated table with "Non-Allocated Resources" and "Allocated Resources" types and use this new field as source of slicer.

Then you can write a measure formula to extract the selection to compare with current calculation results and return flag.  

After these steps, you can use the formula on the ‘visual level filter’ to interact and filter records based on slicer selections.

Regards,

Xiaoxin Sheng

Yes, exactly! This is what I did and managed to achieve my desired results. 

I made a Calculated Table where I summarized the employees by Date and Emp ID and then made a calculated column in my main Fact Table where I concatenated Date - Emp ID and made a Relation with this new Calculated Table using this Composite Key. 

 

Now, I was easily able to filter out records using this new Calculated Table. Thank you so much for the response! 
I am not sure if this is the most efficient way of solving this problem however, but it does solve the issue. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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