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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Responsive Resident
Responsive Resident

How to sum a cost based on field in another related table.

I have PBI Desktop from March 2023. I am trying to sum costs with a wipcategoryid of "10" or "50". Wipcategoryid looks like a number but is a string.

I have these tables with these fields:

Table: Jobcost
jobid (the job number)
actcode (activity code)
actcost (actual cost, this is sometimes null)


Table: ActivityCode
ActivityCode (connects to Jobcost.actcode)
Wipcategoryid (what I need to filter on)


There are other tables that connect to Jobcost. 


The relationship between Jobcost.actcode and ActivityCode.Activitycode is many to many for some reason.


Columns in my report table viz: jobid, Postage (a measure or column)


What I need: For each jobid in the table viz, sum all Jobcost.actcost records where ActivityCode.WipcategoryID="10" or "50".


I have tried to copy the Wipcategoryid to my Jobcost table with this column: `WipCatId = RELATED(Activitycode[jcwipcatid])` but I got an error "The column 'ActivityCode[jcwipcatid]' either doesn't exist or doesn't have a relationship to any table available...'. When in my relationships I link Jobcost.actcode to ActivityCode.Activitycode. But RELATED() cannot be used in a many-to-many relationship, which I have. See


I have tried these as columns and measures added to the Jobcost table and none have worked:


Measure: PostFrtMeas = CALCULATE(SUM('Jobcost'[jcactcost]), OR(RELATED(Activitycode[jcwipcatid])="10", RELATED(ActivityCode[jcwipcatid])="50"))) The error I get is "Column 'jcactcost' in table 'Jobcost' cannot be found or may not be used in this expression."


Column: PostFrtCol = CALCULATE(SUM('Jobcost'[jcactcost]), OR(Activitycode[jcwipcatid]="10",ActivityCode[jcwipcatid]="50"))
The error I get for this is The error I get is "Column 'jcactcost' in table 'Jobcost' cannot be found or may not be used in this expression."


Any ideas how to get this to work? I can't seem to find any formulas in tutorials that make filter criteria based on a connected but different table. And the Microsoft documentation does not say whether or not other tables can be used in various expressions or formulas.

Thank you!


Update: Ok I have fixed this. I changed the source SQL to link the 2 tables Jobcost.actcode with Activitycode.Activitycode. I also had renamed Jobcost.jcactcost to actcost so that part is also fixed.


Please consider this closed.


Helpful resources

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.


Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.