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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

3 Connected Tables and adding a measure

Hi, 

 

I have 3 tables that are connected. (One is from a SQL database and two from an excel file. 

 

Screenshot 2025-06-17 144538.png

 

Here is the graph its showing. I am trying to add a measure that takes the difference between active staff and budget.

 

Screenshot 2025-06-17 144601.png

 

When I add the measure to the graph, it messes up all the numbers. 

 

Screenshot 2025-06-17 145206.png

 

1 ACCEPTED SOLUTION
v-echaithra
Community Support
Community Support

Hi @Anonymous ,

Thank you for reaching out to Microsoft Community.
COUNTA and SUM operate in different table contexts, this results in an incorrect aggregation when used in visuals like matrices. Try this DAX measure:
Difference in Total to Budgeted =
VAR Staffcount = CALCULATE(COUNTA('HR table'[Full Name]))
VAR Budgeted = CALCULATE(SUM('dir or ind'[Budget]))
RETURN
Staffcount - Budgeted

If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

Thanks,
Chaithra E.


View solution in original post

4 REPLIES 4
v-echaithra
Community Support
Community Support

Hi @Anonymous ,

Thank you for reaching out to Microsoft Community.
COUNTA and SUM operate in different table contexts, this results in an incorrect aggregation when used in visuals like matrices. Try this DAX measure:
Difference in Total to Budgeted =
VAR Staffcount = CALCULATE(COUNTA('HR table'[Full Name]))
VAR Budgeted = CALCULATE(SUM('dir or ind'[Budget]))
RETURN
Staffcount - Budgeted

If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

Thanks,
Chaithra E.


Anonymous
Not applicable

Thank you @v-echaithra

 

I think I need to change the context of the formula a bit. When I add that field in, it adds morerows to the graph. I tried adding in the filter all, and also tried using Allexcept. It is then showing the correct amount of rows but the numbers are not adding up correctly.  

 

Here is the formula I tried to use that created the correct row count to match, but the numbers are wrong. It should take the total of open postions + Active count - budget
Screenshot 2025-06-18 114948.png
correct graph row count but wrong numbers under difference1 column

Screenshot 2025-06-18 115005.png

 When I just add the equation without any filters, it adds department rows of the same value. 

Screenshot 2025-06-18 115033.png

 

Anonymous
Not applicable

Turns out the formula is not filtering with the rest of the columns when I use a filter on the same page. Not sure how to fix this issue though. 

Anonymous
Not applicable

Here is the measure I used 

 

Difference in Total to Budgeted = COUNTA('HR table'[Full Name])-(SUM('dir or ind'[Budget]))

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.