Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills 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

PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors