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
gghlyon
Frequent Visitor

Additional filter on TreatAs limiting Values

Hi,

 

I have a ENGINEER table, and an unrelated TICKET table where I'm trying to sum hours with a measure.  I can't link them for other reasons.

 

I wish to filter the ticket table by the engineer name which is fine I see that treatas works here.

However, I would also like to restrict the team manually within the measure as well

 

Starting point is
All hours = CALCULATE(sum(TICKET[ActualHours]),TREATAS(VALUES('ENGINEER'[FullName]),TICKET[HelpdeskEmployeeName]))
 
I can't figure out how to also add a filter here so I only get the engineers for one Department.  I can manually list them in the Treatas so I know it will work, but I can't apply this within the same calculate.  Have tried simply adding as a filter within calculate as below, but also tried to create a mid variable table of values of just the engineers in this department.  Either it breaks, or the filter just doesn't work (i see the result for all engineers not just the ones in the dept i want).
 
For example trying to just see the hours for Rocketry department = 
Rocketry Hours = CALCULATE(sum(TICKET[ActualHours]),'ENGINEER'[Dept]="Rocketry",TREATAS(VALUES('ENGINEER'[FullName]),TICKET[HelpdeskEmployeeName]))
 
This just gives same result as first formula.
 
Any assistance appreciated.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @gghlyon ,

You can follow the steps below to get it:

1. Create a slicer base on the field 'ENGINEER'[Dept]

2. Create a measure as below to get Rocketry Hours 

Rocketry Hours =
VAR _depts =
    ALLSELECTED ( 'ENGINEER'[Dept] )
VAR _engineers =
    CALCULATETABLE (
        VALUES ( 'ENGINEER'[FullName] ),
        FILTER ( 'ENGINEER', 'ENGINEER'[Dept] IN _depts )
    )
RETURN
    CALCULATE (
        SUM ( 'TICKET'[ActualHours] ),
        FILTER ( 'TICKET', 'TICKET'[HelpdeskEmployeeName] IN _engineers )
    )

 

If the above one can't help you, please provide some raw data in your tables 'ENGINEER' and 'TICKET' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @gghlyon ,

Has your problem been resolved? If so, could you please mark the helpful reply as 'Answered'? This will assist others in the community who may encounter a similar issue. Thank you.

Best Regards

Anonymous
Not applicable

Hi @gghlyon ,

You can follow the steps below to get it:

1. Create a slicer base on the field 'ENGINEER'[Dept]

2. Create a measure as below to get Rocketry Hours 

Rocketry Hours =
VAR _depts =
    ALLSELECTED ( 'ENGINEER'[Dept] )
VAR _engineers =
    CALCULATETABLE (
        VALUES ( 'ENGINEER'[FullName] ),
        FILTER ( 'ENGINEER', 'ENGINEER'[Dept] IN _depts )
    )
RETURN
    CALCULATE (
        SUM ( 'TICKET'[ActualHours] ),
        FILTER ( 'TICKET', 'TICKET'[HelpdeskEmployeeName] IN _engineers )
    )

 

If the above one can't help you, please provide some raw data in your tables 'ENGINEER' and 'TICKET' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

johnt75
Super User
Super User

Try

Rocketry Hours =
VAR FilteredEngineers =
    CALCULATETABLE (
        VALUES ( 'ENGINEER'[FullName] ),
        'ENGINEER'[Dept] = "Rocketry"
    )
VAR Result =
    CALCULATE (
        SUM ( TICKET[ActualHours] ),
        TREATAS ( FilteredEngineers, TICKET[HelpdeskEmployeeName] )
    )
RETURN
    Result

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.