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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Robbinsbk
Regular Visitor

Add a calculated column to a Matrix visualization

I am using a Power Bi matrix visualization to display a series of data. I have two datasources.  The first is my data I want to display and the second is my target values.  There is a Mant to One relationship between my source data and my target data.  Power BI piked up the relationship when I imported the data. 2020-02-26_16-10-41.gif

 

I add to my source data a new column that is simply two of the colmns add together.  I add a second column which is the target from second table.  There are no slicers for filtering.  The data in the first two columns displays correctly.

 

I want to add a 3rd column that is my new column(named Target) - my new column(named SuperMarket WIP)  

This is my issue is doesn't display the correct amount.  It only gives me the options to choose the agregate functions.  As you can see from my snapshot, the calculation isn't what I am looking for.  My expectation are on the first row for example the new column (named Count of Gap) is 27 I expected - 3

 

SuperMarket WIP = (SuperMarketData[Before SuperMarket] + SuperMarketData[In SuperMarket])
Target = RELATED(TargetData[TARGET])
 
I believe it is related to filtering but can't figure the correct format.
 
I have tried a couple different scenarios
 
Gap = SuperMarketData[Target] - SuperMarketData[SuperMarket WIP]
 
Gap = RELATED(TargetData[TARGET] - (SuperMarketData[Before SuperMarket] + SuperMarketData[In SuperMarket])
 
Gap = RELATED(TargetData[TARGET]) - CALCULATE(SUMX(SuperMarketData, SuperMarketData[Before SuperMarket] + SuperMarketData[In SuperMarket]),FILTER(SuperMarketData, SuperMarketData[Die Type] = RELATED(TargetData[DIE_TYPE])))
 
Any help or suggestions would be greatly appreciated.
 
Thank you.
1 ACCEPTED SOLUTION

Got it to work.  (Used a new name) What I did was use a measure.  I only wanted one value for the target. The relationship is Many to One.  Since there is only one value in the target type for each category I used MIN (again because there is only one value I could have just as easily used MAX) instead of sum for the target.

 

To Be Released = CALCULATE( MIN(SuperMarketData[Target]),ALLSELECTED(TargetData)) - CALCULATE( SUM(SuperMarketData[Before SuperMarket]) + SUM(SuperMarketData[In SuperMarket]),ALLSELECTED(TargetData))
 
2020-02-27_9-35-43.gif

 

 

View solution in original post

4 REPLIES 4
Tad17
Solution Sage
Solution Sage

Is your "GAP" column in the matrix a calculated column or a measure? Make sure it is a calculated column and then select SUM as the aggregation.

 

If this helps please kudo.

If this solves your problem please accept it as a solution.

Yes, it is a calculated column.  I tried a couple different calculations but none is working.

 

Gap = SUM(SuperMarketData[Target]) - SUM(SuperMarketData[SuperMarket WIP])
Gap = CALCULATE(SUM(SuperMarketData[SuperMarket WIP]) - SUM(SuperMarketData[Target]))

Gap = CALCULATE(SUM(SuperMarketData[Target]) - SUM(SuperMarketData[SuperMarket WIP]),FILTER(SUMMARIZE(SuperMarketData,SuperMarketData[Die Type]),SuperMarketData[Die Type]=RELATED(TargetData[DIE_TYPE])))
 

Got it to work.  (Used a new name) What I did was use a measure.  I only wanted one value for the target. The relationship is Many to One.  Since there is only one value in the target type for each category I used MIN (again because there is only one value I could have just as easily used MAX) instead of sum for the target.

 

To Be Released = CALCULATE( MIN(SuperMarketData[Target]),ALLSELECTED(TargetData)) - CALCULATE( SUM(SuperMarketData[Before SuperMarket]) + SUM(SuperMarketData[In SuperMarket]),ALLSELECTED(TargetData))
 
2020-02-27_9-35-43.gif

 

 
Greg_Deckler
Community Champion
Community Champion

OK, a lot going on here, need sample data in text format and then what you expect in your new column and why. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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