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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Super User
Super User

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


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.