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
SariW
Regular Visitor

DAX measure to sum a column in table A but can be filtered by variables in linked table B

I'm fairly beginner at DAX and am really struggling to figure this out.

 

I have a table (Table A below) that has a number of estimating stages with a total cost for each. I then need a column to calculate the latest cost estimate for that row, based on stage of estimating that the package ID as a whole is at. This is done with a mix of measures and a calculated column.

 

I first created measures for each of the total columns to give a total by Package ID, see below using Total C as an example:

 
Total C by PKG =
    CALCULATE(
        SUM('Table A'[Total C]),
        ALLEXCEPT('Table A','Table A'[Package ID])
    )

 

I then created a calculated column for Estimated Final Cost (EFC) using SWITCH to give the cost for each row from the latest estimating stage.

 

The calculated EFC column DAX formula is:

 
ESTIMATED FINAL COST =
    SWITCH(true(),
        [Total C by PKG] <> 0, 'Table A'[Total C],
        [Total B by PKG] <> 0, 'Table A'[Total B],
        'Table A'[Total A]
        )
 
This column seems to be working fine in the context of the table.
 
I now need to input this measure into a visual, showing EFC by Package, and another visual by Discipline. Discipline comes from table B, and the tables are linked by the Package ID column.
 
I have then created another measure based off this calculated column to sum the EFC column:
 
EFC = sum('Table A'[ESTIMATED FINAL COST])
 
When I input the EFC measure into a bar graph with Discipline (from Table B) on the x-axis, the visual only shows the total EFC against a (Blank) discipline (see image at the bottom of the post).
 
I need this EFC measure (and other measures that will be calculated in a similar way) to be able to be filtered by Discipline from Table B, or be broken out in a table with Package Name from Table B.
 
Any assistance would be appreciated!
 
TABLE A
 
PACKAGE IDDescriptionTOTAL ATOTAL BTOTAL CESTIMATED FINAL COST
80233266Piling prep & distribution of material          26,665    31,332     31,332
80233266Install Pile           74,057    70,112     70,112
51480994Supply capping       769,108    769,108
51480994Stockpile capping       384,565    384,565
53683210Install trackside equipment foundation       570,666  571,000  555,637  555,637

 

TABLE B

 

DisciplinePackage IDPackage Name
ENABLING80233266TRACK ENABLING
BUILDING34284038OHW ENABLING
CIVIL51480994CSR STAGE 1
UTILITIES87811765RACK CROSSINGS - GAS
BUILDING85985437AREA 1 PERMANENT OHW
BUILDING93623530AREA 2 PERMANENT OHW
RAIL53683210ESDS
RAIL86890401SUBSTATION
RAIL85201749LOCAL SIGNAL CONNECTION

 

Bar graph with X-axis set to Discipline (from Table B), and Y-axis the EFC measure.

SariW_0-1715733317194.png

 

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Create a Dim Table of Package ID and build a relationship (Many to One and Single) from the Package ID of both Fact tables to this Dim Table.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

 

Thanks for the response. Table B in this case is a dimension table (I believe). The Package ID column in Table B only has distinct values, so the link between Table A and Table B, using Package ID, is a many to one relationship. Sorry if I haven't fully understood your response, I'm learning on the fly!

You are correct.  Please share the download link of the PBi file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

 

I have just created a new dashboard based on the example tables and formulas I listed in my original post, and now everything is working. The example above was a heavily simplified version of my actual data set, so I'm guessing it's not the formulas that are the problem, but something to do with my actual data.

 

I'll have to dig further into my data and see if I can figure this out. Unfortunately I can't share the actual data set due to confidentiality, but any thoughts on areas I could look in would be appreciated.

 

Thanks,

Sari

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.